如何将另一个开发人员的分支合并到我的分支中?

我还是个新手。我们的组织使用 叉拉式模型来管理对主分支的更改。每个开发人员在添加新特性时都会分叉主分支。我一直关注其他开发人员在他们自己的分支中所做的提交,并且有时候希望将这些更改合并到我自己的分支中。我需要采取哪些步骤来完成这一任务?

159869 次浏览

once you have the branch in question in your repository as, say, anotherdev/master remote branch, you do the git merge anotherdev/master.

You first need to add the other developer repository as a remote.

git remote add otherrep uriToOtherRep

Then you fetch changes from there

git fetch otherrep

And then you merge the branch from the remote repository into yours

git merge otherrep/branchname

Happy merging!

You can also do "git pull", it'll pull the changes of all the branches.

git pull

You can run git merge into your current branch

git merge origin <branchname>

Let's say you are currently working on branch feature/feature_a and you want to merge the changes made in another branch called feature/feature_b to feature/feature_a. The following commands should do the trick:

git checkout feature/feature_b
git pull
git checkout feature/feature_a
git merge feature/feature_b