Skip to content

Instantly share code, notes, and snippets.

@Thilakeswar
Created August 24, 2023 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thilakeswar/11c08625108b9336b45ba5961f2cb31b to your computer and use it in GitHub Desktop.
Save Thilakeswar/11c08625108b9336b45ba5961f2cb31b to your computer and use it in GitHub Desktop.
For resetting both Author and Committer information for Commits of a branch
Step - 1 : Set git user name and password,
i) For setting globally,
->Hit below commands
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "MY_NAME@example.com"
->Alternatively open ~/.gitconfig and add/edit the below information,
[user]
name = FIRST_NAME LAST_NAM
email = MY_NAME@example.com
ii) If you have multiple accounts in Gitlab, Github and using different ones for each of your local repository, you need to update for each repository, if it varies from the global ones.
-> Open <PathToLocalRepo>/.git/config and add/edit the below information,
[user]
name = FIRST_NAME LAST_NAM
email = MY_NAME@example.com
Step - 2 : Resetting wrong author and commiter information for one/more commits of a branch.
i) Checkout to local branch using below command
git checkout <LocalBranchName>
ii) Rebase local branch against origin
git rebase -i origin <LocalBranchName>
iii) An interactive vi editor will be opened and commits will be listed.
For the commits you need to update the author and committer information, change the word "pick" to "edit".
iv) Press `ESC` and enter ":wq" to save and exit the vi editor
v) Hit the below commands consecutively until the rebase process is completed,
git commit --amend --author="Thilakeswar <MY_NAME@example.com>" --no-edit
git commit --amend --reset-author --no-edit
git rebase --continue
vi) Once rebased, hit "git log" to confirm the author and committer information change for each commit you intended.
vii) Force push for the change to be reflected in remote as well.
git push -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment