如何使用 git 使我的分支与 master 保持同步?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5691557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I keep my branch up to date with master with git?
提问by Nic Hubbard
I have a bug fix in my master, and I also want my branch to get that bug fix. What git
command do I use?
我在我的主人中有一个错误修复,我也希望我的分支得到那个错误修复。git
我使用什么命令?
回答by John Doty
Assuming you're fine with taking all of the changes in master, what you want is:
假设您可以接受 master 中的所有更改,那么您想要的是:
git checkout <my branch>
to switch the working tree to your branch; then:
将工作树切换到您的分支;然后:
git merge master
to merge all the changes in master with yours.
将 master 中的所有更改与您的更改合并。
回答by Chetan
If your branch is local only and hasn't been pushed to the server, use
如果您的分支仅在本地并且尚未推送到服务器,请使用
git rebase master
Otherwise, use
否则,使用
git merge master
回答by manojlds
You can use the cherry-pick to get the particular bug fix commit(s)
您可以使用cherry-pick来获取特定的错误修复提交
$ git checkout branch
$ git cherry-pick bugfix
回答by Alan Haggai Alavi
If you just want the bug fix to be integrated into the branch, git cherry-pick
the relevant commit(s).
如果您只想将错误修复集成到分支中,git cherry-pick
则需要相关的提交。