Git 将 master 拉入源上的远程分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34881800/
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 pull master into remote branch on origin
提问by goutham_kgh
I have a two remote branches: origin/master
and origin/my_remote_feature
我有两个远程分支:origin/master
和origin/my_remote_feature
I have checked out my_remote_feature
using git checkout --track -b origin/my_remote_feature
我已经签出my_remote_feature
使用git checkout --track -b origin/my_remote_feature
There are a couple of changes made in master that I want to pull into my branch that tracks the remote branch. How do I go about it ?
我想将 master 中的一些更改拉到跟踪远程分支的分支中。我该怎么做?
回答by Ryan
git rebase origin/master
Is all you really need to do. then resolve any conflicts. You might need
这就是您真正需要做的。然后解决任何冲突。你可能需要
git rebase --continue
if there are are conflicts. This will put my_remote_feature commits on top of the HEAD of origin/master. Re-writing history as it were.
如果有冲突。这会将 my_remote_feature 提交放在 origin/master 的 HEAD 之上。照原样改写历史。
git merge origin/master
Is also a possibility. However, you will find that all the commits to master will become part of your remote_feature commit history. Which you may not want. Generally rebase is better to keep your commit history pristine. :)
也是一种可能。但是,您会发现对 master 的所有提交都将成为您的 remote_feature 提交历史记录的一部分。你可能不想要。通常 rebase 更好地保持您的提交历史原始状态。:)
回答by Olalekan Sogunle
One cool way to do this is to rebase origin/master into your remote branch. You can follow the following rebase workflow;
一种很酷的方法是将 origin/master 变基到您的远程分支。您可以遵循以下变基工作流程;
Check out to your local my_remote_feature branch and pull changes from that branch.
git pull origin my_remote_feature
Do a
git fetch
Then rebase origin/master like
git rebase origin/master
If all works successfully, push your new updates.
git push origin my_remote_feature
查看您本地的 my_remote_feature 分支并从该分支中提取更改。
git pull origin my_remote_feature
做一个
git fetch
然后 rebase origin/master 就像
git rebase origin/master
如果一切正常,请推送您的新更新。
git push origin my_remote_feature
This will bring all the changes on master on top of your changes in my_remote_feature. If there are any conflicts, you will have to resolve them along the way and make sure you add files after resolving conflicts then do a git rebase --continue
after every conflict resolutions.
这会将 master 上的所有更改置于 my_remote_feature 中的更改之上。如果有任何冲突,您必须一路解决它们,并确保在解决冲突后添加文件,然后git rebase --continue
在每次冲突解决后执行。
You can refer to the git rabase docfor more information.
您可以参考git rabase 文档了解更多信息。
回答by René H?hle
Merge the master
branch to your feature branch and then push the changes.
将master
分支合并到您的功能分支,然后推送更改。