From: W. Trevor King Date: Sat, 30 Nov 2013 01:26:14 +0000 (-0800) Subject: Merge branch 'v1.x' X-Git-Tag: v2.0 X-Git-Url: http://git.tremily.us/?p=swc-git-example.git;a=commitdiff_plain;h=523842c86d54bf0b6881eec55fc3190db5142e51;hp=9eba52ed830f39a59e024a1598395140337eaf36 Merge branch 'v1.x' Bring in changes from the maintenance branch with: $ git merge --log v1.x The pre-merge situation is: $ git log --graph --topo-order --oneline --decorate --all * 97941bc (HEAD, master) cheat-sheet.md: Mention 'config', 'diff', 'branch', 'remote', ... | * 9eba52e (tag: v1.1, v1.x) cheat-sheet.md: Fix 'Incorperate' -> 'Incorporate' typo |/ * 36d8c70 (tag: v1.0) cheet-sheet.md: Add a Git-specific cheat sheet ... And the post-merge situation will be: $ git log --graph --topo-order --oneline --decorate --all * XXXXXXX (HEAD, tag: v2.0, master) Merge branch 'v1.x' |\ * | 97941bc cheat-sheet.md: Mention 'config', 'diff', 'branch', 'remote', ... | * 0eba52e (tag: v1.1, v1.x) cheat-sheet.md: Fix 'Incorperate' -> 'Incorporate' typo |/ * 36d8c70 (tag: v1.0) cheet-sheet.md: Add a Git-specific cheat sheet * 3ba6fc9 (public/master) Merge branch 'mit-license' |\ | * 41d3ea1 (public/mit-license, mit-license) COPYING: Fill in the and markers | * e8051dc COPYING: Add MIT license for this project |/ * c481fb5 README.md: Document the syntax used in the README * b089fb8 README.md: Begin versioning by explaining the project goals This is much like our earlier merge in 3ba6fc9, except that this time there has been development in the master branch (97941bc), so a fast-forward merge would not be possible in this case. If you want to invoke merge with the `--no-ff` option anyway, that's fine, but it won't change the default handling in this case. The v2.0 tag is going to come from a: $ git tag v2.0 after I stop editing this commit message for XXXXXXX. --- diff --git a/cheat-sheet.md b/cheat-sheet.md index 08258e5..ab4c027 100644 --- a/cheat-sheet.md +++ b/cheat-sheet.md @@ -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