[英]Git merge of a feature branch to master shows changes outside of the feature change
I generally use the following steps: 我通常使用以下步骤:
After step 4 if I see the commits in the 'master' branch one of them shows "Merge branch 'master' into ". 在第4步之后,如果我在'master'分支中看到提交,则其中一个显示为“将分支'master'合并为”。 This commit shows all the changes made by others while I was working on my feature.
该提交显示了我在使用功能时其他人所做的所有更改。 Which is fine but when I see this commit in master, it seems confusing and it shows huge commits.
很好,但是当我在master中看到此提交时,它似乎很混乱并且显示了巨大的提交。 These were commits to the feature branch.
这些是对功能分支的提交。 Why are they appearing in the master branch?
为什么它们出现在master分支中?
Is there a way to merge feature branch to master but also ensure that only the feature changes show in the master commit log? 有没有一种方法可以将功能分支合并到主分支,又可以确保仅特征更改显示在主提交日志中?
This is why you rebase. 这就是为什么要变基。 When you're ready to merge master into your branch to get the latest code from master, instead do
git rebase master
in your feature branch. 当您准备将master合并到分支中以从master获得最新代码时,请在功能分支中使用
git rebase master
。 This basically rolls back all your commits in your feature branch, gets the latest commits from master to "update" your feature branch, then replays your commits on top of those. 基本上,这将回滚功能分支中的所有提交,从主服务器获取最新的提交以“更新”功能分支,然后在这些之上重播您的提交。 This way when you finally merge your feature branch into master, you don't have a merge commit to begin with.
这样,当您最终将功能分支合并到master中时,就没有合并提交。
You can see a nice diagram explanation here . 您可以在此处看到一个不错的图表说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.