git 如何从另一个分支获取更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37709298/
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 to get changes from another branch
提问by Anthony
I am currently working on featurex
branch. Our master branch is named branch our-team
. Since I started working on featurex
, more changes have been made to branch our-team
. Before I push featurex
for merging, I would locally like to get all changes from our-team
branch into featurex
so that I can ensure everything works as expected.
我目前在featurex
分支上工作。我们的主分支名为 branch our-team
。自从我开始工作以来featurex
,对 branch 进行了更多的更改our-team
。在我推动featurex
合并之前,我希望在本地将所有更改从our-team
分支导入,featurex
以便我可以确保一切按预期工作。
I have done this locally to get all the latest changes from our-team
.
我已在本地完成此操作以从our-team
.
git checkout our-team
git pull
How can I do that?
我怎样才能做到这一点?
采纳答案by JulCh
You can use rebase, for instance, git rebase our-team
when you are on your branch featurex
例如,当你在你的分支上时,你可以使用rebasegit rebase our-team
featurex
It will move the start point of the branch at the end of your our-team
branch, merging all changes in your featurex
branch.
它将在分支的末尾移动分支的起点our-team
,合并分支中的所有更改featurex
。
回答by Jad Chahine
go to the master branch
our-team
- git checkout our-team
pull all the new changes from
our-team
branch- git pull
go to your branch
featurex
- git checkout
featurex
- git checkout
merge the changes of
our-team
branch intofeaturex
branch- git merge
our-team
- or git cherry-pick
{commit-hash}
if you want to merge specific commits
- git merge
push your changes with the changes of
our-team
branch- git push
转到主分支
our-team
- git checkout 我们的团队
从
our-team
分支中提取所有新更改- 拉
去你的分行
featurex
- 结帐
featurex
- 结帐
将
our-team
分支的更改合并到featurex
分支中- 合并
our-team
- 或者git cherry-pick
{commit-hash}
如果你想合并特定的提交
- 合并
使用
our-team
分支的更改推送您的更改- 推
Note: probably you will have to fix conflicts after merging our-team
branch into featurex
branch before pushing
注意:在将our-team
分支合并到featurex
分支之后,您可能必须在推送之前修复冲突
回答by heisenberg
git fetch origin our-team
or
或者
git pull origin our-team
but first you should make sure that you already on the branch you want to update to (featurex).
但首先你应该确保你已经在你想要更新的分支上(featurex)。
回答by Pierre Fouilloux
You are almost there :)
你快到了:)
All that is left is to
剩下的就是
git checkout featurex
git merge our-team
This will merge our-team into featurex.
这会将我们的团队合并到 featurex 中。
The above assumes you have already committed/stashed your changes in featurex, if that is not the case you will need to do this first.
以上假设您已经在 featurex 中提交/隐藏了您的更改,如果不是这种情况,您需要先执行此操作。