git fetch不获取远程分支



前段时间,Igit fetch从远程回购的分支。我们称它为origin/thebranch所以我有这个,还有我的本地thebranch我在上面签出一个新的分支,然后做我的工作之后,在将新分支重新定位到最新的主服务器

之后,我将其推入远程服务器。旧的origin/thebranch在重置后留在原地

所以现在我被告知origin/thebranch有新的工作,所以我做了git fetch origin thebranch

我得到

From <remote repo url>
* branch            thebranch -> FETCH_HEAD

结果什么都没发生分支(远程和本地)都在同一个地方,我没有得到"分支"的最新提交

我能做什么?

(顺便说一句,thebranch是由一个同事写的,所以我想我能做的是有限的)

您需要使用git pull命令而不是git fetch,将远程更改合并到本地分支。Git取回不会做合并部分。

git pull origin thebranch

如果您的本地数据已经是最新的,那么您所描述的序列将匹配您应该看到的。


您可以使用git ls-remote来双重检查分支在远程服务器上的状态:

git ls-remote origin refs/heads/<thebranch>

将此处的sha与git show -s origin/<thebranch>进行比较。

最新更新