-
-
Save pertrai1/e54132383dfdef466f6c03e909a28be4 to your computer and use it in GitHub Desktop.
Revisions
-
vecano revised this gist
Jan 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -125,7 +125,7 @@ Tracking -------- git branch -u origin/<remote_branch> # Start tracking remote branch from current branch. http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch/2286030#2286030 git branch -u origin/<remote_branch> [<branch>] # Start tracking remote branch from <branch> or current branch if not specified. git branch -d -r origin/<remote_branch> # Stop tracking remote branch. NOTE: Remote branch is not removed. git push -u <remote> <branch> # Create a remote branch from local branch and track it -
vecano revised this gist
Jan 21, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -127,6 +127,7 @@ Tracking git branch -u origin/<remote_branch> # Start tracking remote branch from current branch. http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch/2286030#2286030 git branch -u origin/<remote_branch> <branch> # Start tracking remote branch from <branch> git branch -d -r origin/<remote_branch> # Stop tracking remote branch. NOTE: Remote branch is not removed. git push -u <remote> <branch> # Create a remote branch from local branch and track it Stashing -
vecano revised this gist
Jan 21, 2014 . 1 changed file with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -103,11 +103,15 @@ More Examples: http://git-scm.com/docs/git-reset#_examples Diff'ing -------- Use `--stat` to show summary of changes instead of full diff. `[<commit>]` defaults to HEAD if omitted. `<commit>` can be a branch name. git diff # Show unstaged changes git diff --staged # Show staged changes git diff HEAD # Show staged and unstaged changes git diff <commit> # Show changes in your working tree relative to <commit> git diff [<commit>]..[<commit>] # Show diffs between two commits. Whitespace can be used instead of '..' when using both <commit>'s. git diff [<commit>]...[<commit>] # Show diff in second <commit> from common ancestor (the point the two branches split). Note the three dots. Working with Remotes -
vecano revised this gist
Jan 21, 2014 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -91,9 +91,10 @@ Use the `--all` option to show all branches, not only the current one. Undoing ------- `[<commit>]` defaults to HEAD. More Examples: http://git-scm.com/docs/git-reset#_examples git reset [<commit>] # Unstage changes git reset --hard [<commit>] # Undo commits permanently git reset --soft 'HEAD^' # http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit/927386#927386 git reset HEAD@{1} # Undo last pull @@ -127,13 +128,14 @@ Tracking Stashing -------- Stash references have the form stash@{0}. WIP means Work In Progress. An empty `[<stash>]` defaults to the latest stash. git stash list # Show stash list git stash [save] [<message>] # Stash current changes with optional message git stash show [-p] [<stash>] # Show stash diffstat or '-p' to show patch git stash apply [<stash>] # Apply stash git stash pop [<stash>] # Apply stash and drop it git stash drop [<stash>] # Drop stash git stash branch <branchname> [<stash>] # Create and switch to a new branch with the <stash> applied to it git stash clear # Remove all stashes @@ -146,7 +148,6 @@ Rule of Rebasing: "Only rebase local branches" git checkout <branch>; git rebase master # Apply changes on top of master - http://git-scm.com/book/en/Git-Branching-Rebasing - http://blogs.atlassian.com/2013/10/git-team-workflows-merge-or-rebase/ - http://stackoverflow.com/questions/16336014/git-merge-vs-rebase - http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/ @@ -175,6 +176,7 @@ Using Shell Aliases gl='git log --pretty=oneline --abbrev-commit --graph --decorate' glog='git log --graph --pretty=format":%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset"' gloga='glog --all' gf='git fetch' gm='git merge' gp='git push' grh='git reset HEAD' -
vecano revised this gist
Jan 21, 2014 . 1 changed file with 48 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,11 +13,58 @@ Configuring Starting -------- git init [<directory>] # Start! Creates the .git directory inside <directory> or in the current directory if not specified These are the files created on a newly init'ed git repository: <pre> .git ├── HEAD ├── branches/ ├── config ├── description ├── hooks/ │ └── ... ( Sample hooks, see http://git-scm.com/book/ch7-3.html ) ├── info/ │ └── exclude ├── objects/ │ ├── info │ └── pack └── refs/ ├── heads/ └── tags/ </pre> Cloning ------- git clone <url> [<directory>] # Clone a repo and optionally give it an alternative <directory> name Adding Files ------------ git add <file> # Stage a single file git add . # Stage everything git add -u # Stage updated tracked files git add -p [<file>] # Stage hunks of file(s) interactively Committing ---------- 50/72-Rule: 50 or fewer characters for summary and wrap description at 72 characters. Separate the summary and description with an empty line. The description should explain the motivation behind the change and how it is different from the previous implementation. git commit -v # Commit by opening an editor which displays a unified diff git commit --amend # Modify the last commit with the current index changes - http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html - http://ablogaboutcode.com/2011/03/23/proper-git-commit-messages-and-an-elegant-git-history/ - http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message Branching -
vecano revised this gist
Jan 20, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,6 +75,7 @@ Tracking git branch -u origin/<remote_branch> # Start tracking remote branch from current branch. http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch/2286030#2286030 git branch -u origin/<remote_branch> <branch> # Start tracking remote branch from <branch> git branch -d -r origin/<remote_branch> # Stop tracking remote branch. NOTE: Remote branch is not removed. git push -u <remote> <branch> # Create a remote branch from local branch and track it Stashing -
vecano revised this gist
Jan 18, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,14 +80,16 @@ Tracking Stashing -------- Stash references have the form stash@{0}. WIP means Work In Progress. `[<stash>]` default to latest stash git stash list # Show stash list git stash [save] [<message>] # Stash current changes with optional message git stash show [-p] [<stash>] # Show stash diffstat or '-p' to show patch git stash apply [<stash>] # Apply stash git stash pop [<stash>] # Apply stash and drop it git stash drop [<stash>] # Drop stash git stash branch <branchname> [<stash>] # Create and switch to a new branch with the <stash> applied to it git stash clear # Remove all stashes Rebasing -------- -
vecano revised this gist
Jan 18, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -139,3 +139,4 @@ References - http://git-scm.com/book - http://git-scm.com/docs - http://www.ndpsoftware.com/git-cheatsheet.html - http://gitref.org/ -
vecano created this gist
Jan 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,141 @@ Quick Git Reference =================== Configuring ----------- git config --global user.name "<First Last>" git config --global user.email <[email protected]> git config --global core.editor <vim> git config --global color.ui true Starting -------- git init # Start! git add <file> # Stage a single file git add . # Stage everything git add -u # Stage updated tracked files git commit -v # Commit by opening an editor which displays a unified diff Branching --------- git checkout <branch> # Switch between branches git checkout -b <branch> # Create and switch to a branch git branch -d <branch> # Remove local branch git branch -avv # Show extra verbose information about branches and their remotes Displaying Logs --------------- Use the `--all` option to show all branches, not only the current one. git log ..<other_branch> # List changes that will be merged into current branch. git log --graph --all # Show log graph for all branches git log --graph --abbrev-commit # Show log graph git log --graph --decorate --oneline # Show condensed log graph git log --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset' # Show log graph including commiter information Undoing ------- `[<commit>]` defaults to HEAD. More Examples: http://git-scm.com/docs/git-reset#_examples git reset [<commit>] # Unstage files git reset --hard [<commit>] # Undo commits permanently git reset --soft 'HEAD^' # http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit/927386#927386 git reset HEAD@{1} # Undo last pull Diff'ing -------- git diff <branch>..<other_branch> # Show diffs between branches git diff ..<other_branch> # Show diff with current branch git diff --stat ..<other_branch> # Show only names and status of changed files git diff --name-status ..<other_branch> # Show git diff ...<other_branch> # Show diff from common ancestor (merge base) to the head of what will be merged. Note the three dots. Working with Remotes -------------------- git remote add <remote_name> <url> # Add remote git remote -v # Show remote urls after their names Tracking -------- git branch -u origin/<remote_branch> # Start tracking remote branch from current branch. http://stackoverflow.com/questions/520650/how-do-you-make-an-existing-git-branch-track-a-remote-branch/2286030#2286030 git branch -u origin/<remote_branch> <branch> # Start tracking remote branch from <branch> git branch -d -r origin/<remote_branch> # Stop tracking remote branch. NOTE: Remote branch is not removed. Stashing -------- Stash references have the form stash@{1}. WIP means Work In Progress. `[<stash>]` default to latest stash git stash # Stash current changes git stash list # Show stash list git stash show --text [<stash>] # Show stash diff git stash drop [<stash>] # Drop stash git stash branch <branchname> [<stash>] # Create and switch to a new branch with the <stash> applied to it Rebasing -------- Rule of Rebasing: "Only rebase local branches" git checkout <branch>; git rebase master # Apply changes on top of master - http://git-scm.com/book/en/Git-Branching-Rebasing - http://blog.experimentalworks.net/2009/03/merge-vs-rebase-a-deep-dive-into-the-mysteries-of-revision-control/ - http://blogs.atlassian.com/2013/10/git-team-workflows-merge-or-rebase/ - http://stackoverflow.com/questions/16336014/git-merge-vs-rebase - http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/ - http://www.derekgourlay.com/archives/428 Using Additional Packages ------------------------- gem install git-smart # https://github.com/geelen/git-smart gem install git-up # https://github.com/aanand/git-up gem install omglog # https://github.com/benhoskings/omglog while true; do clear; git --no-pager log --decorate --oneline --graph --all -n 10; sleep 3; done # Quickly display git repository's commit graph with live update. See https://github.com/benhoskings/omglog for a more permanent solution. Using Shell Aliases ------------------- ga='git add' gb='git branch' gci='git commit -v' gco='git checkout' gd='git diff' gdc='git diff --cached' gl='git log --pretty=oneline --abbrev-commit --graph --decorate' glog='git log --graph --pretty=format":%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset"' gloga='glog --all' gm='git merge' gp='git push' grh='git reset HEAD' grhh='git reset HEAD --hard' gss='git status -s' References ---------- - http://git-scm.com/book - http://git-scm.com/docs - http://www.ndpsoftware.com/git-cheatsheet.html