当我克隆一个远程存储库时
git clone 'repo_url'git pullgit status我收到这条消息 -
On branch master
Your branch and 'origin/master' have diverged,
and have 41 and 20 different commits each, respectively
Run Code Online (Sandbox Code Playgroud)
当我使用时,git pull -a我没有这个问题.
远程仓库上的东西是不同步的吗?与HEAD和主人?我如何解决它?
编辑1:
当我运行git branch -a:这就是它的样子......
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/clothes
remotes/origin/dunnesBranch
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
编辑2:
在我看来,origin/master并没有指向最新的代码......然后我运行'git clone'然后运行
git reset --hard origin/master
'git pull'并尝试合并因冲突而失败...
我想......远程仓库的HEAD指向最新的提交,origin/master指向另一个不同的旧提交...我可以在运行git show时验证这一点...
不确定原因,除非:
git push --force在origin别人,你促成的克隆回购,而你拉着同样的回购git config --get remote.origin.fetch)不是+refs/heads/*:refs/remotes/origin/*.但是你可以很容易地重置master:
git reset --hard origin/master
Run Code Online (Sandbox Code Playgroud)
git branch -u origin/master master
Run Code Online (Sandbox Code Playgroud)
并确保您的推送策略是' simple'(为了将当前分支推送到远程存储库中的相同名称,只有当它被设置为跟踪那里具有相同名称的分支时):
git config --global push.default simple
Run Code Online (Sandbox Code Playgroud)
评论摘要:根本原因似乎与用于这些操作的1.7.x版本的git有关.它似乎与最新的git1.8.3一起工作.
| 归档时间: |
|
| 查看次数: |
6991 次 |
| 最近记录: |