Thursday, February 13, 2014

How to git commit --amend


If you have multiple commits, you can either squash your commit or amend your commit. Below are the steps to amend your commit

myname@myname-WS /c/Users/myname/mynames-alfresco-dev (ta1747)
$ git add .

myname@myname-WS /c/Users/myname/mynames-alfresco-dev (ta1747)
$ git commit --amend

This will open the vi editor, change the commit message and then exit [wq]

[ta1747 cb03152] ta1747 - Change the upload URL
 2 files changed, 5 insertions(+), 3 deletions(-)

myname@myname-WS /c/Users/myname/mynames-alfresco-dev (ta1747)
$ git log
commit cb0315286b26e69f8d58b4262e35394101e18150
Author: David Sundersingh
Date:   Thu Feb 13 11:53:06 2014 -0800

    ta1747 - Change the upload URL


myname@myname-WS /c/Users/myname/mynames-alfresco-dev (ta1747)
$ git diff rewrite
myname@myname-WS /c/Users/myname/mynames-alfresco-dev (ta1747)
$ git push origin +ta1747

Counting objects: 41, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 1.64 KiB | 0 bytes/s, done.
Total 21 (delta 14), reused 0 (delta 0)
To git@gitserver:myname/alfresco-dev.git
 + 16ff671...cb03152 ta1747 -> ta1747 (forced update)

No comments: