目录
最近不知道做了什么操作。发现git pull 的时候报错 Your configuration specifies to merge with the ref XXXX。如下
> git pull
Your configuration specifies to merge with the ref 'refs/heads/some_master'
from the remote, but no such ref was fetched.
使用git branch -a 看不到远程分支。(本例解决办法)
>git branch -a
* some_master
(END)
按网上的说法,是本地分支和远程分支对不上了。于是我使用
vim .git/config
查看分支是否正确
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = git@github.com:orgName/myProject.git
fetch = +refs/tags/v1.0-release:refs/tags/v1.0-release
[branch "some_master"]
remote = origin
merge = refs/heads/some_master
从branch "some_master"看来,那个 分支的指向应该是没有问题的。但是看看 remote "origin" 好像有问题。
fetch = +refs/tags/v1.0-release:refs/tags/v1.0-release
应该是指向了某个tag,这个tag应该是不能获取到其他分支信息的。于是,使用下面命令
> git fetch -a # 获取所有分支信息
>git branch -a # 展示所有分支信息
更新分支信息后,结果和之前的一样。
* some_master
(END)
说明确实是 origin 指向错误。那就找到了
解决办法
把 .git/config 中的 remote "origin" 的 fetch 改成 +refs/heads/*:refs/remotes/origin/* ,如:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = git@github.com:orgName/myProject.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "go_eventer_master"]
remote = origin
merge = refs/heads/some_master
再去 git pull 没有问题了。