What you are asking for is to rewrite history n to 0 commits back. This is generally a bad idea as it would make you repo out of sync from the remote and any other repo that is based on it. This would further complicate things so that others wouldn't be able to merge anymore and would require any other repo to delete their branch and pull down the newly modified one. In which case, you might as well just start a new branch and add the comments to that. In any case, this'll get a little messy.
To do this, you have your merges that you would be reviewing (as an example, we'll use commits A
, B
and C
) and then go back to A
, branch off that (we'll call that branch review, and the original pull-request):
...A --B --C (pull-request)
\
A' (review)
git checkout HEAD{3}
git checkout -b review
Then do your comment modifications and check them in.
git add . # or specify the specific files
git commit -m "message" --author="original author"
Or if you want the same message/author and don't want to type it out, you can use the following, which I would either put into a script or an alias git command:
git add $(git diff-tree --no-commit-id --name-only -r <sha-of-A>)
git commit -m "$(git rev-list --format=%B <sha-of-a>)" --author="$(git rev-list --format=%an <sha-of-A>)"
Could also be done automatically by retrieving the appropriate sha from the appropriate parent, but I'm not exactly sure how to distinguish between the branch parent and the merge parent atm.
Next merge B
into review
git merge <sha-of-B>
Then do your comment modifications and check them in. (see above).
Keep doing this till you're done and you have:
...A --B --C (pull-request)
\ \ \
A'--B'--C' (review)
You can then merge back into your original branch if you wish or just give that review branch back to the person from which you are reviewing.
git
,push
refers to pushing your commits to another repo. The command you are referring to iscommit
.