git pull origin/branch1 && git merge origin/branch1
git pull
git pull 实际上是这两个命令的别名:git fetch + git merge 所以你的命令的第二部分是无用的。
获取更改的方法是这样的 - 几个选项:
# Update your local repo with the latest code:
git fetch --all --prune
# Merge the changes (you already did a pull)
git merge origin branch1
或:
# grab & merge the latest changes into your current branch
git pull origin branch1
rebase
如果您希望您的更改位于其他更改之上,那么您可以在拉取内容时使用--rebase 标志。
# As before - update your local repo with the latest code:
git fetch --all --prune
# Merge the changes with the rebase flag
git pull --rebase origin/branch1
图片来源:http://blogs.atlassian.com/
Stash + rebase 自动
你有那些你可以设置的配置:
rebase.autoStash + pull.rebase
rebase.autoStash
设置为 true 时,在操作开始前自动创建一个临时存储,并在操作结束后应用它。
这意味着您可以在脏的worktree 上运行rebase。
但是,请谨慎使用:rebase 成功后的最终存储应用程序可能会导致重大冲突。默认为 false。
pull.rebase
如果为 true,则在获取的分支之上重新设置分支,而不是在运行“git pull”时从默认远程合并默认分支。
git config pull.rebase true
git config rebase.autoStash true