简体   繁体   English

如何将更改从主服务器中提取并合并到当前分支中?

[英]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.

相关问题 如何在本地将当前分支合并到 master 中,有冲突,忽略 master 中的更改? - How to merge current branch into master locally, with conflicts, ignoring changes in master? 在分支上签出时,从主节点拉出并合并或变基到当前分支,然后签出该分支 - While checked out on a branch, pull from master and merge or rebase to current branch then checkout the branch 如何将更改从主分支更新到当前分支 - How to update changes from Master branch to current branch 成功的git merge into master不会在GitHub上显示任何更改,也不会在master分支中显示git之后 - Successful git merge into master is not showing any changes on GitHub or after git pull from master branch git pull origin分支想要在干净的当前master分支上合并 - git pull origin branch wants a merge on clean current master branch 如何在没有更改的情况下将分支合并到git中的master分支中? - How to merge the branch with no changes into master branch in git? 如何将分支合并到具有更改或不更改的主分支? - How to merge branch to a master branch with or without changes? 如何将更改从 master 中的分支拉到子分支? - How do I pull changes from a branch in master to a subbranch? 如何将主分支合并到我当前的分支 - How to merge master branch to my current branch 有没有办法从我的分支中提取主更改? - Is there a way to pull the master changes from my branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM