开发者

Merging changesets in git for a code review

开发者 https://www.devze.com 2023-01-05 17:24 出处:网络
I have around 50 relevant commits on my local git repo, of this list I want to show in a code review only my commits.

I have around 50 relevant commits on my local git repo, of this list I want to show in a code review only my commits.

But they are mixed with other people commits, and some of my commits are corrections to others, so I don't want to go commit by commit because I would step twice in the same code, for the original and for the correction.

The best thing for me would be to do something like this:

git combine-commits 4 9 20 35 67 90 102 > myfile.di开发者_如何学Goff

In such a way that 67 fixes an error on 20 and the diff shows the corrected version.

Is there any way of geting this?


One way would be to create a new working branch based at a point before the oldest commit you want to include, git cherry-pickthe commits you want to review onto that branch and extract the diff from the new branch (just git diff start-ref when you have your temporary branch checked out). Once you've finished the review you can throw away the temporary branch. One thing to watch out for is that the sha refs on your temporary branch will be different to the ones you started with, but I don't expect that will be a problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消