Reputation: 818
I did a git rebase
to amend my previous commit. The structure is like: HEAD->another_person's_commit->my_commit->...
I modified my_commit
and git rebase --continue
then pushed, the first commit made by another person get "changed", the status becomes person commit with me
. I.E, he is the commit author and I am a committer who "changed" the commit. I understand git rebase
will change all commit from the amend one (like creating a new branch from a point it changed).
So the question is would it possible to remove my name on his commit?
Upvotes: 1
Views: 225
Reputation: 11649
In Git, any change to the commit - even just a different (amended) commit actually makes a child commit turn into a new child commit.
If before rebase, you have:
x - x - x - you - him - x
Then after rebase you really have:
x - x - x - you - him - x
\
you' - him' - x'
even if you give him'
the exact same commit message as him
, because in the hash of him'
is a different parent commit (you'
) then is in him
, so that means the hash will change (even if the committer info stayed the same) - it's not the same commit any more.
Now, granted the rebase actually removes the links to you - him - x
, and they will get garbage collected, leaving just:
x - x - x - you' - him' - x'
There's no reason to remove you as the commiter - it shows the truth about what happened. You could "fake it" by changing your user.name and user.email to his name and email and then re-amend his commit ... and there's probably a low-level plumbing command or another way to do this directly with flags. But, why? There's not anything to gain. He's the original author, and you are now the committer of this new you'
commit.
If you want to clarify what happened, you can amend his commit message as well to add a note: [recommitted due to rebase, no changes] or similar.
Upvotes: 1