From c092386f50b4ca927a5acea54e262c6c301c4221 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 29 Apr 2015 09:58:42 -0700 Subject: [PATCH] More Git notes --- notes.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/notes.md b/notes.md index 5f89025c4..6101de45c 100644 --- a/notes.md +++ b/notes.md @@ -48,6 +48,23 @@ You can also do this with files from other branches, and such. `man git-checkout The rest of the Internet will tell you to use `git reset --hard`, but this resets all uncommitted changes you’ve made in your working copy. Type this with care. +Amending a commit +--- + +Sometimes I'm too quick with the "Commit and Push" button, and I've left a stale comment in the comment field. +To correct that: + + git commit --amend -m "New comment" + +Unfortunately, updating the remote is not as simple as `git push`, which will complain: + + Updates were rejected because the tip of your current branch is behind its remote counterpart. + Integrate the remote changes (e.g. 'git pull ...') before pushing again. + +But in this case, there's nothing to pull, so force the push (this example assumes the current branch is *master*): + + git push -f origin master + Node "Cheat Sheet" ===