1. 程式人生 > >git 初始化

git 初始化

git 初始化 pull 失敗

在 gitlab 上新建了一個工程後,添加了 README 作為第一次提交。在本地目標文件夾下執行:

git init; git clone <工程url> 後將工程 commit 到本地,準備 push 時候發生了

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: ‘git pull ...‘) before pushing again.

錯誤。原因是準備推送的地址和原來的地址不一致(我也不知道為啥)。


解決方法:

vim .git/config

[core]

repositoryformatversion = 0

filemode = true

bare = false

logallrefupdates = true

ignorecase = true

precomposeunicode = true

[remote "origin"]

url = [email protected]:xxx/xxx.git <此處是你的工程鏈接地址>

fetch = +refs/heads/*:refs/remotes/origin/*

pushurl = [email protected]:xxx/xxx.git <此處是你的工程鏈接地址>

[branch "master"]

remote = origin

merge = refs/heads/master


再執行git pull --allow-unrelated-histories

就可以push了


本文出自 “Echo和你一起飛” 博客,請務必保留此出處http://5052416.blog.51cto.com/5042416/1950703

git 初始化