From 8d2c660b3c7c9697aa1a7b5b7f69803ca8d55140 Mon Sep 17 00:00:00 2001 From: Joe Block Date: Fri, 22 Aug 2014 13:33:56 -0700 Subject: [PATCH 1/8] Add some command aliases. --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index d61035c..cbb5a26 100644 --- a/README.md +++ b/README.md @@ -373,3 +373,33 @@ README.md foo.txt ``` Voila! We got our removed file back. Git reflog is also useful when rebasing goes terribly wrong. + + +## I want to add aliases for some git commands + +On OS X and Linux, your git configuration file is stored in ```~/.gitconfig```. I've added some example aliases I use as shortcuts (and some of my common typos) in the ```[aliases]``` section as shown below: + +``` +[aliases] + a = add + amend = --amend + c = commit + ca = commit --amend + ci = commit -a + d = diff + dc = diff --changed + dif = diff + ds = diff --staged + f = fetch + loll = log --graph --decorate --pretty=oneline --abbrev-commit + m = merge + one = log --pretty=oneline + outstanding = rebase -i @{u} + psuh = push + puhs = push + pul = pull + s = status + wc = whatchanged + wip = rebase -i @{u} + zap = fetch -p +``` From 9fba446438d8d924ba49acf40f57d5940c0f0c3d Mon Sep 17 00:00:00 2001 From: Joe Block Date: Fri, 22 Aug 2014 13:53:19 -0700 Subject: [PATCH 2/8] Add example - unpushed aliases to log @{u} --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cbb5a26..9ea496e 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,7 @@ On OS X and Linux, your git configuration file is stored in ```~/.gitconfig```. puhs = push pul = pull s = status + unpushed = log @{u} wc = whatchanged wip = rebase -i @{u} zap = fetch -p From cf111f959c4b625ea6d4bc3c6d6b2852e9f895cc Mon Sep 17 00:00:00 2001 From: Joe Block Date: Fri, 22 Aug 2014 14:07:36 -0700 Subject: [PATCH 3/8] Add instructions for deleting stale branches --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d61035c..a728638 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,13 @@ And finally, let's cherry-pick the commit for bug #14: (14)$ git cherry-pick 5ea5173 ``` + +## I want to delete local branches that were deleted upstream +Once you merge a pull request on github, it gives you the option to delete the merged branch in your fork. If you aren't planning to keep working on the branch, it's cleaner to delete the local copies of the branch so you don't end up cluttering up your working checkout with a lot of stale branches. + +```bash +$ git fetch -p +``` ## I accidentaly deleted my branch From 9d45f6a2737a12b4df9bf8878f76c6f30ff6d30b Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Wed, 27 Aug 2014 23:02:00 -0700 Subject: [PATCH 4/8] Add stronger language for force push It will conflicts in the source history, and may interfere with other branches regardless of amount of developers on the team. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d61035c..04a7dac 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ For clarity's sake all examples in this document use customized bash prompt in o Note that, as with rebasing (see below), amending **replaces the old commit with a new one**, so you must force push (`-f`) your changes if you have already pushed the pre-amended commit to your remote. Be careful when you do this – *always* make sure you specify a branch! -In fact, if you are not the only developer using the repo **avoid force pushing**. It is best to create and push a new commit rather than force-pushing the amended commit as it has the potential to mess with the shared history. +In general, **avoid force pushing**. It is best to create and push a new commit rather than force-pushing the amended commit as it has will cause conflicts in the source history for any other developer who has interacted with the branch in question or any child branches. ## I need to combine commits From 0ed6dbf70604b184e6122bf878fac2fdd65d0f92 Mon Sep 17 00:00:00 2001 From: Joe Block Date: Fri, 29 Aug 2014 14:37:42 -0700 Subject: [PATCH 5/8] Remove typo aliases, add co = checkout --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ea496e..bb39996 100644 --- a/README.md +++ b/README.md @@ -386,18 +386,15 @@ On OS X and Linux, your git configuration file is stored in ```~/.gitconfig```. c = commit ca = commit --amend ci = commit -a + co = checkout d = diff dc = diff --changed - dif = diff ds = diff --staged f = fetch loll = log --graph --decorate --pretty=oneline --abbrev-commit m = merge one = log --pretty=oneline outstanding = rebase -i @{u} - psuh = push - puhs = push - pul = pull s = status unpushed = log @{u} wc = whatchanged From 177d178c50d3f5fe42f3bf810895dc977a1a0d3e Mon Sep 17 00:00:00 2001 From: Aldric Giacomoni Date: Tue, 4 Nov 2014 11:52:05 -0500 Subject: [PATCH 6/8] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d61035c..7ea2016 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ And finally, let's cherry-pick the commit for bug #14: ``` -## I accidentaly deleted my branch +## I accidentally deleted my branch If you're regularly pushing to remote, you should be safe most of the time. But still sometimes you may end up deleting your branches. Let's say we create a branch and create a new file: From e575e47aaa073e017df75b7259a11b19a4ea2cbb Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Sat, 7 Mar 2015 10:39:30 -0800 Subject: [PATCH 7/8] Added commit amend simple message --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d61035c..4e4dd43 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ A [guide for astronauts](http://www.jsc.nasa.gov/news/columbia/fr_generic.pdf) ( For clarity's sake all examples in this document use customized bash prompt in order to indicate the current branch and whether or not there are staged changes. The branch is enclosed in parentheses, and a `*` next to the branch name indicates staged changes. +## I wrote the wrong thing in a commit message + +```sh +git commit --amend +``` + ## I need to add staged changes to the previous commit ``` From 3786c8832d49beef2e6acbff1160a7b505b80192 Mon Sep 17 00:00:00 2001 From: "Ciro S. Costa" Date: Fri, 1 Aug 2014 13:14:57 -0300 Subject: [PATCH 8/8] fixes typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 114a491..4fd3fd4 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ If you need to change all of history, see the man page for 'git filter-branch' Create the new branch while remaining on master: ``` -(master)$ git branch new-branch +(master)$ git branch new-branch ``` Find out what the commit hash you want to set your master branch to (`git log` should do the trick). Then reset to that hash. @@ -257,7 +257,7 @@ Author: Alex Lee Date: Tue Jul 22 15:39:27 2014 -0400 Bug #21 - Added CSRF protection - + commit 5ea51731d150f7ddc4a365437931cd8be3bf3131 Author: Alex Lee Date: Tue Jul 22 15:39:12 2014 -0400