Why doesn't git fetch update local branch?
This question already has an answer here:
To view the differences between your local branch and the remote branch before merging them, you can use git diff
, as outlined in this question, after executing git fetch
.
If you want to execute the merge of your remote branch with your local branch without committing it immediately to allow you to review the result, you can use git pull --no-commit
(as described on git-scm.com). The --no-commit
option prevents Git from automatically committing a merge that may be part of the pull, which would allow you to review the merge result before committing it.
git fetch
downloads commits from the remote branch, but doesn't update your workspace. You won't see the commits until they are merged into your local branch.
git pull
is a combination of git fetch
and git merge
- this is why git pull
appears to "fix" this behaviour.
下一篇: 为什么不git获取更新本地分支?