Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Last active January 28, 2023 19:30
Show Gist options
  • Save mortymacs/9e90ca114939bda9aa239b475f9a3adb to your computer and use it in GitHub Desktop.
Save mortymacs/9e90ca114939bda9aa239b475f9a3adb to your computer and use it in GitHub Desktop.
How to change author of last commits

First find your commit:

$ git log

Then copy the last commit ID (one commit after your target commit. it means your target commit + 1).

Then start rebase:

$ git rebase -i 234234rfsdfrq3213412e412

This command will open your EDITOR, change your target commits from pick to edit. THIS ACTION IS SO IMPORTANT Then save and close your editor.

Then amend your commit (with your details):

$ git commit --amend --author="Morteza Nourelahi Alamdari <[email protected]>"

Then keep rebase continue:

$ git rebase --continue

Again try do amend line. Again try keep rebase continue line.

Until rebase command says (all edit lines completed successfully):

Successfully rebased and updated 

Now your commits are changed successfully.

Now if you want to push your commits to the server, try to push it with -f option:

$ git push origin master -f
@jovialcore
Copy link

How do you this for all commits. Thank you

@mortymacs
Copy link
Author

How do you this for all commits. Thank you

I think you need to use filter-branch https://stackoverflow.com/q/750172/2338672

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment