Amending Git commits

In my experience with Git, i have run into situations where i had made a commit in error, especially when resolving merge conflicts or sometimes i find my commit very non descriptive and need amending.

To remove a commit made in error entirely do:

git reset --soft HEAD~1
 # and then 
git reset --hard # this will reset the current branch

Another issue that may arise is, may be you have already push the unwanted change in error to the remote origin branch.
No worries at all, Git is very forgiving.

After you must have done the above steps do this to update (rewind) remote origin.

git push origin head -f

To amend commit message i do:

git commit --amend

Another scenario where git shines is amending commits.. May be you are working from a new system and have not set the git config –globla user.email to the right email address.
All that is required is running this command:

git commit --amend --author=username@domain.com

It all depend on what part of your commit you would like to change. for a full usage guide do:

git commit --usage


Ciao !!