cheat-sheet.md: Mention 'config', 'diff', 'branch', 'remote', ...
authorW. Trevor King <wking@tremily.us>
Mon, 10 Jun 2013 19:13:07 +0000 (15:13 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 30 Nov 2013 00:10:14 +0000 (16:10 -0800)
Also mention:

* checkout
* rebase
* commit --amend
* reset

With the exception of 'commit --amend', these were all used or
mentioned in Matt Davis' Git-via-GitHub notes [1].

After editing cheat-sheet.md in my text editor, staging and committing
it was the usual:

  $ git add cheat-sheet.md
  $ git commit --all --verbose

[1]: http://git.tremily.us/?p=swc-version-control-git.git;a=commit;h=fda4a1a751211ccbf9deac1d5bea7d7f1ad0f033

cheat-sheet.md

index 0b6a9bd849e57533536646dad30178ad10c1499c..e3030f81bf9e3cf1d152c483397ba5434831f3ed 100644 (file)
@@ -1,3 +1,16 @@
+Configuring
+===========
+
+* Tell Git who you are:
+
+        $ git config --global user.name 'User Name'
+        $ git config --global user.email 'user@email.com'
+
+* Customize the user interface:
+
+        $ git config --global core.editor nano
+        $ git config --global color.ui auto
+
 Basic use
 =========
 
@@ -37,9 +50,23 @@ Merging
 
         $ git add $FILES
 
+* Instead of merging `origin/master` into your local branch, you can
+  rebase your local branch onto `origin/master` (useful options:
+  `-i`):
+
+        $ git rebase origin/master
+
 Comparing changes
 =================
 
+* Compare the current working directory to the staging area:
+
+        $ git diff
+
+* Compare the staging area to the last commit:
+
+        $ git diff --cached
+
 * Compare the current working directory to the last commit:
 
         $ git diff HEAD
@@ -51,14 +78,15 @@ Browsing history
 
         $ git status
 
-* View past commits:
+* View past commits (useful options: `--oneline`, `--graph`,
+  `--decorate`, `--stat`, …):
 
         $ git log
 
 * Who wrote this line, and what were they thinking?
 
         $ git blame $FILES
-        $ git show $COMMIT_HASH
+        $ git show $COMMIT
 
 Recovering old versions
 =======================
@@ -96,6 +124,54 @@ Provenance
   increment `package.__version__` by hand
   (e.g. [pygit2][pygit2-version]).
 
+Branches
+========
+
+* What branch am I on?  What other branches are there?
+
+        $ git branch
+
+* Make a new branch (e.g. `some-feature`):
+
+        $ git branch some-feature
+
+* Change the current branch (e.g. to `some-feature`) and update the
+  staging area and working directory:
+
+        $ git checkout some-feature
+
+Remotes
+=======
+
+* List configured remotes (URL nicknames):
+
+        $ git remote
+
+* List configured remotes with push/pull URLs:
+
+        $ git remote -v
+
+* Add a new remote:
+
+        $ git remote add $NAME $URL
+
+Manipulating history
+====================
+
+* Squash new changes onto the most recent commit:
+
+        $ git commit --amend …
+
+* Move the current branch to `$COMMIT` without touching the staging
+  area or working directory:
+
+        $ git reset $COMMIT
+
+* Move the current branch to `$COMMIT` while also resetting the
+  staging area and working directory:
+
+        $ git reset --hard $COMMIT
+
 
 [git-version-gen]: http://git.kernel.org/cgit/git/git.git/tree/GIT-VERSION-GEN
 [git-makefile]: http://git.kernel.org/cgit/git/git.git/tree/Makefile