[英]How to pull and merge changes into current branch from master?
I am working on a branch called create
. 我正在开发一个名为create
的分支。 I have to pull the changes that are made into my branch. 我必须将所做的更改提取到我的分支中。 I already have done - 我已经做了 -
git checkout master
git pull origin master
and now I have to merge it. 现在我必须合并它。 What's the way to merge it? 合并它的方式是什么?
Considering that you have updated the master
on your local using 考虑到您已使用本地更新了master
服务器
git checkout master && git pull origin master
You can pull the changes to create
branch also using - 您也可以使用以下命令提取更改以create
分支 -
git checkout create && git pull origin master
Edit - As suggested by @Zarwan, rebase is also another option. 编辑 - 正如@Zarwan所建议的那样,rebase也是另一种选择。 For details on when to use which, please look into When do you use git rebase instead of git merge? 有关何时使用哪个的详细信息,请查看何时使用git rebase而不是git merge?
It is recommended to rebase your feature branch with master rather than merge it. 建议使用master重新绑定功能分支,而不是将其合并。 Details below 详情如下
rebase - if you are still working on your feature branch create
, then rebase your feature branch to master
. rebase - 如果您仍在使用功能分支create
,则将功能分支重新设置为master
。 This allows you to work on your branch with the latest version of master
as if you've just branched off your master. 这允许您使用最新版本的master
在您的分支上工作,就像您刚刚分支主人一样。
git checkout create
git rebase master
merge - use it when you finish your task on your feature branch and want to merge it to other branches. 合并 - 在功能分支上完成任务时使用它,并希望将其合并到其他分支。 For example, when you finish your work on create
branch and want to merge it with master
. 例如,当您在create
branch上完成工作并希望将其与master
合并时。
git checkout master
git merge create
git push origin master
This operation also generates a merge commit on your master
branch. 此操作还会在master
分支上生成合并提交。
git checkout create
git rebase origin master
This will take the changes on your branch and apply them on top of the current master branch, and your branch will be updated to point to the result. 这将对您的分支进行更改并将其应用于当前主分支之上,并且您的分支将更新为指向结果。 In other words, master
will be merged into create
. 换句话说, master
将合并为create
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.