git pull origin master does not update origin/master?

非 Y 不嫁゛ 提交于 2019-11-29 23:38:41

It's a bit weird, but if you use git pull [remote] <refspec> it actually doesn't update the remote refs. It sort of makes sense if you think about it a certain way: since you're specifying a specific ref to fetch, it doesn't have to look up anything about your remote branches, so it doesn't inherently know what remote branch it should update. It of course could figure it out, and I wouldn't be surprised if it gets fixed eventually, but that's the existing behavior. (There may be messages on the mailing list about it - I don't know.)

You can easily work around it, though. If you use git pull origin/master, since you're specifying what to fetch via a remote branch, it should update that remote branch. And if you're on your master branch anyway (or any other branch tracking origin/master), you can just do git pull and let it fill in the defaults, and it will update remote branches.

This is documented in the git-pull man page, most concisely under EXAMPLES but also elsewhere. The relevant part:

Merge into the current branch the remote branch next:

$ git pull origin next

This leaves a copy of next temporarily in FETCH_HEAD, but does not update any remote-tracking branches. Using remote-tracking branches, the same can be done by invoking fetch and merge:

$ git fetch origin
$ git merge origin/next

it seems you have forked the repository and your forked branch is not updated with the latest code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!