有时候我在一个分支上工作,想要合并自分支创建以来在origin/master上进行的更改。仅仅使用git merge master
通常是不够的,因为本地的master可能没有来自远程master的更改,所以我发现自己必须这样做:
# save any uncommitted changes (if there are any)
git stash
# update master first:
git checkout master
git pull
# back to where we were:
git checkout <previous branch>
git stash pop # omit if git stash not done
# and finally the actual merge:
git merge master
当然,有一种更简单的方法,只需要一个或两个git命令吗?