Fix common mistakes while working with git
Saibal Roy • April 4, 2020quick-tips productivity-tips git
Welcome to my website and this is Saibal with yet another post to share my knowledge with you all.
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"
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@example.com>"
If it's a git branch where only you were working:
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='John Doe'; GIT_AUTHOR_EMAILfirstname.lastname@example.org'; GIT_COMMITTER_NAME='John Doe'; GIT_COMMITTER_EMAILemail@example.com';" HEAD
Never fear doing mistakes it helps you learn even better.
Happy learning folks!