Search code examples
gitgit-squash

Commit Author Not showing recent commiter name when doing Git Squash


I have a branch and few commits done by some other person. I committed few more changes to the same branch. Now i am squashing all commits to one single commit using below commands.

git rebase -i HEAD~2

From the displayed commit list changed the first commit from pick to reword second one from pick to squash then modified the commit message to some meaningful msg git push --force

Now when i see on the remote the author/committer name is still showing the old author name. Is there a way i can have this name changed to mine as i am the recent committer?


Solution

  • The easiest way to do that is by amending the squashed commit with the --reset-author option:

    When used with -C/-c/--amend options, or when committing after a conflicting cherry-pick, declare that the authorship of the resulting commit now belongs to the committer. This also renews the author timestamp.

    In your case, you can simply do this after you've squashed all the commits into one:

    git commit --amend --no-edit --reset-author
    

    This will set the current user.name and user.email as the author of the commit.