Fix common mistakes while working with git

Saibal Roy • April 4, 2021

quick-tips productivity-tips git

Everybody is not perfect. So, mistakes do happen when working with git too.

Mistake 1: Typo mistakes done with the commit message. I think most of us fall into this a number of times.


git commit --amend -m "an updated commit message"

Check out to understand much better

Mistake 2: If you have seperate git accounts for office and personal work then this issue quite happens that you commit with the wrong account. After doing several commits you realize it. Couple of workarounds with the scenarios are listed below.

If it's only for the last commit you can easily change it with this one line command. Cool and awesome!

git commit --amend --author="John Doe <[email protected]>"

If it's a git branch where only you were working:

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='John Doe'; GIT_AUTHOR_EMAIL='[email protected]'; GIT_COMMITTER_NAME='John Doe'; GIT_COMMITTER_EMAIL='[email protected]';" HEAD

Never fear doing mistakes it helps you learn even better.

Happy learning folks!