当我从另一个分支feature1创建一个新的分支feature2时,它还包含来自feature1的未与master合并的已更改文件。有没有办法分离feature1和feature2中的更改?
答案 0 :(得分:0)
It is not possible to mark the branch feature2 as "do never show the changes from feature1 when comparing this branch". If that were possible, a problem would occur when merging feature2: Either the changes from feature1 would be merged - in this case stuff would be merged which is not shown in a diff. Or the changes from feature1 would not be merged, leading to problems if feature2 is based on those changes (e.g. a new function added in feature1 is called in feature2).
However you can show all commits which are part of feature2 but neither of feature1 nor of master:
git log ^feature1 ^master feature2
By adding the -p
option you can also see the diff for each of the commits to review these changes.
答案 1 :(得分:0)
在我看来,您希望从feature2
和master
中的最新提交开始feature1
,因此将feature2
合并到{在master
赢得feature1
之前的任何提交之前{1}} {1}}。您可以使用git-merge-base命令查找由两个分支共享的最新提交来执行此操作:
feature1