From 73e07977ca8c87e2665706a98e925c0e7dd37968 Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Sun, 8 Oct 2017 08:13:58 -0400 Subject: [PATCH] Add a NOTE for "git commit --amend" to emphasize replacement of old commit. While it might be obvious from that section as to how amending works, it doesn't hurt to truly drive home the mechanics of amending. --- book/02-git-basics/sections/undoing.asc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/book/02-git-basics/sections/undoing.asc b/book/02-git-basics/sections/undoing.asc index fb4450510..0c0dbfb9e 100644 --- a/book/02-git-basics/sections/undoing.asc +++ b/book/02-git-basics/sections/undoing.asc @@ -31,6 +31,14 @@ $ git commit --amend You end up with a single commit – the second commit replaces the results of the first. +[NOTE] +==== +It's important to understand that when you're amending your last commit, you're not so much fixing it as _replacing_ it entirely with a new, improved commit that pushes the old commit out of the way and puts the new commit in its place. +Effectively, it's as if the previous commit never happened, and it won't show up in your repository history. + +The obvious value to amending commits is to make minor improvements to your last commit, without cluttering your repository history with commit messages of the form, ``Oops, forgot to add a file'' or ``"Darn, fixing a typo in last commit''. +==== + [[_unstaging]] ==== Unstaging a Staged File