Git:从另一个分支获取更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3124601/
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
Git: getting changes from another branch
提问by FunLovinCoder
I have a project which uses git and I'd like to start a new branch to add a major new feature.
我有一个使用 git 的项目,我想创建一个新分支来添加一个主要的新功能。
Under the main
branch, I'll continue to add bug fixes and minor features. At regular intervals I'd like to pull the changes from the main branch into my "major new feature" branch. What's the best way to do this?
在main
分支下,我将继续添加错误修复和次要功能。我想定期将更改从主分支拉入我的“主要新功能”分支。做到这一点的最佳方法是什么?
Eventually, I'll merge the "major new feature" branch into the main branch.
最终,我会将“主要新功能”分支合并到主分支中。
采纳答案by David Winslow
git checkout featurebranch && git merge master
git checkout featurebranch && git merge master
You can do this as many times as you like; it won't affect master and you will be able to easily do it the other way around whenever you find out you are done with the feature branch.
您可以根据需要多次执行此操作;它不会影响 master 并且当你发现你已经完成了功能分支时,你将能够轻松地以相反的方式做到这一点。
回答by VonC
git checkout featurebranch && git rebase master
As long as you haven't pushed yet, it is better to replay your changes on top of master.
只要您还没有推送,最好在 master 上重放您的更改。
See:
看: