Info Desk: How to amend last commit in git using Visual Studio ?

I just came across one good thing. It is small but quite useful.

If you have just committed your change in git and you want amend or change in that particular commit. Is It possible ?

YES

There are always two possible way.

  1. Create change and commit again that file. This seems to be a good option but it will add to history of branch and later if it is goes to main branch. ( if you don't choose squash merge)

  2. Now second option , this is bit cool but with limitation. Option is "Amend Previous Commit".

1.png

  • To make this work you have to first make change in file you want to amend. ( For example i did change program.cs). After this you will see "Amend Previous commit" is active.

2.png

  • Above step will amend the previous commit. -You will see that change edited by you is added to previous commit. This is quite helpful as sometime we forgot to change small thing. Like small comment, forgot to add supported file etc.

Hope this will helpful to someone.