Git: Change your last commit

Git seems to be the way to go when it comes to code management nowadays. Also the iCub repository recently moved to Git.

Git has a number of pretty great features, one which I found very helpful is the ability to amend the previous commit. If you are as easily distracted as I am it might happen that you accidentally left something out of your last commit (or commited the binary/build directory too). With GIT you don’t have to worry, it can easily be fixed:

All you have to do is stage the extra changes like you would for a normal commit:
git add .
git rm --cached -r build/

And then just commit with the –amend argument.
git commit --amend

I did this with my commit here, you can’t even see that I pushed it before with the build dir :)

You can check the git log --stat to see your amended commit with the extra changes.
More information is available in the Git ‘commit’ documentation.

Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *