Git amend ? Rename previous commit ?


Hey, I use git for two years. I have’nt used git amend till yesterday.

Where u will use this,

Case 1:

git commit -am “old commit”

F***, I forgot to add the files with commit ( untracked files )

then i ll add it again

 git add .

And commit again, but it should come as same commit

 git commit -am “missed file”

Solution:

 git add .

git commit –amend -m “old commit”

or

git commit  amend

This will add to your previous commit. You don need to specify message, if you don’t need new message.

Case 2:

git commit -am “od commit”

F***, I din spell “old” correctly

git commit –amend -m “old commit”

This will replace your previous “od commit” => “old commit”

^ I mostly face these two cases, But never tried amend keyword

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s