git 初始化

在 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了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章