Member-only story
Git, how to undo your Mistake.
Some time , When We are working on git, We do some mistake or some mistakes happen by default. And we want to rectify those mistake. But how we can do that.
- Author name and email id is not proper in my last commit, Now I have to modify it. how can i do it ?
first thing we have to do is , To check username and email id are proper in git config. To see the username and email we have to run below command
git config user.name
git config user.email
Both Command will give set username and email for your git config.
git config --global user.name "krishankant"
git config --global user.email "krishankant@gmail.com"
By using doubledash global parameter, we are setting this config globally. so this username and email will be available for all api.
then last commit Author can be modified using
git commit --amend --author="krishankant <krishankant@gmail.com>"
this command will the author of last commit .
If you want to change several commits, you may rebase interactively and specify the commits you want to change:
git rebase -i origin/master
or
git rebase -i origin/master commithash (Rebase will start from parent of this hashed commit.)# In the rebase list, replace 'pick' with 'edit' (or 'e') for each commit you want to change.