-
-
Save andyfoster/0eaaadc9f81c3962c389c37da6f42c17 to your computer and use it in GitHub Desktop.
Revisions
-
akras14 revised this gist
Sep 23, 2015 . 1 changed file with 2 additions and 2 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 @@ -1,6 +1,6 @@ # Git Cheat Sheet Visit [my blog](http://www.alexkras.com/) or [connect with me on Twitter](https://twitter.com/akras14) ## Commands ### Getting Started @@ -38,7 +38,7 @@ git merge branchname # Merge branch without fast forwarding. This is what pull requests do. # It helps to preserve history of the changes as relavant to that branch # It's an advanced feature, but try it out with GUI to see the difference # between the regular merge and merge --no-ff git merge --no--ff branchname -
akras14 revised this gist
Sep 13, 2015 . 1 changed file with 5 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 @@ -36,7 +36,7 @@ git checkout -b new-branch-name # Merge branch-name into the current branch git merge branchname # Merge branch without fast forwarding. This is what pull requests do. # It helps to preserve history of the changes as relavant to that branch # It's an advance feature, but try it out with GUI to see the difference # between the regular merge and merge --no-ff @@ -76,7 +76,7 @@ git status -s # Add modified file to be commited(aka stage the file) git add filename # Add all modified files to be commited(aka stage all files) git add . # Add only text files, etc. @@ -115,17 +115,17 @@ git reset <commit-hash> # Save current changes, without having to commit them to repo git stash # And later return those changes git stash pop # Return file to it's previous version, if it hasn’t been staged yet. # Otherwise use git reset filename or git reset --hard filename git checkout filename ``` **Comparing changes** ``` bash # See current changes, that have not been staged yet. # Good thing to check before running git add git diff -
akras14 revised this gist
May 1, 2015 . 1 changed file with 3 additions 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 @@ -63,6 +63,9 @@ git log --pretty=format:"%h %s" --graph # See what you worked on in the past week git log --author='Alex' --after={1.week.ago} --pretty=oneline --abbrev-commit # See only changes made on this branch (assuming it was branched form master branch) git log --no-merges master.. # See status of your current git branch. # Often will have advice on command that you need to run git status -
akras14 revised this gist
Apr 22, 2015 . 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 @@ -31,7 +31,7 @@ git branch git checkout branchname # Checkout current branch into a new branch, named new-branch-name git checkout -b new-branch-name # Merge branch-name into the current branch git merge branchname -
akras14 revised this gist
Apr 16, 2015 . 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 @@ -1,6 +1,6 @@ # Git Cheat Sheet Visit [my blog](http://www.alexkras.com/) or [connect with me one Twitter](https://twitter.com/akras14) ## Commands ### Getting Started -
akras14 revised this gist
Apr 16, 2015 . 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 @@ -1,6 +1,6 @@ # Git Cheat Sheet Visit [my blog](http://www.alexkras.com/) or [follow me one Twitter](https://twitter.com/akras14) ## Commands ### Getting Started -
akras14 revised this gist
Apr 16, 2015 . 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 @@ -1,4 +1,4 @@ # Git Cheat Sheet Visit [my blog](http://www.alexkras.com/), or [follow me one Twitter](https://twitter.com/akras14) -
akras14 renamed this gist
Apr 16, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
akras14 revised this gist
Apr 16, 2015 . 1 changed file with 2 additions 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 @@ -1,5 +1,7 @@ # Git CheatSheet Visit [my blog](http://www.alexkras.com/), or [follow me one Twitter](https://twitter.com/akras14) ## Commands ### Getting Started -
akras14 revised this gist
Apr 16, 2015 . 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 @@ -35,7 +35,7 @@ git chekcout -b new-branch-name git merge branchname # Merga branch without fast forwarding. This is what pull requests do. # It helps to preserve history of the changes as relavant to that branch # It's an advance feature, but try it out with GUI to see the difference # between the regular merge and merge --no-ff git merge --no--ff branchname -
akras14 revised this gist
Apr 16, 2015 . 1 changed file with 7 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 @@ -32,7 +32,13 @@ git checkout branchname git chekcout -b new-branch-name # Merge branch-name into the current branch git merge branchname # Merga branch without fast forwarding. This is what pull requests do. # it helps to preserve history of the changes as relavant to that branch # It's an advance feature, but try it out with GUI to see the difference # between the regular merge and merge --no-ff git merge --no--ff branchname # Soft branch delete, will complain if the branch is not merged git branch -d branchname -
akras14 revised this gist
Apr 16, 2015 . 1 changed file with 3 additions 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 @@ -52,6 +52,9 @@ git log # Just google it :) git log --pretty=format:"%h %s" --graph # See what you worked on in the past week git log --author='Alex' --after={1.week.ago} --pretty=oneline --abbrev-commit # See status of your current git branch. # Often will have advice on command that you need to run git status -
akras14 revised this gist
Apr 16, 2015 . 1 changed file with 3 additions 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 @@ -132,6 +132,9 @@ git difftool -d master.. # See only the file names that has changed in current branch git diff --no-commit-id --name-only --no-merges origin/master... # Similar to above, but see statistics on what files have changed and how git diff --stat #Your diff condition ``` ### Working with Remote Branch -
akras14 revised this gist
Apr 2, 2015 . 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 @@ -1,4 +1,4 @@ # Git CheatSheet ## Commands ### Getting Started -
akras14 revised this gist
Apr 2, 2015 . 1 changed file with 4 additions 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,7 +127,11 @@ git diff branch-name git difftool -d # See only changes made in the current branch (compared to master branch) # Helpful when working on a stand alone branch for a while git difftool -d master.. # See only the file names that has changed in current branch git diff --no-commit-id --name-only --no-merges origin/master... ``` ### Working with Remote Branch -
akras14 revised this gist
Mar 20, 2015 . 1 changed file with 2 additions and 2 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 @@ -126,8 +126,8 @@ git diff branch-name # each file one at a time. git difftool -d # See only changes made in the current branch (compared to master branch) git difftool -d master.. ``` ### Working with Remote Branch -
akras14 revised this gist
Mar 20, 2015 . 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 @@ -126,7 +126,7 @@ git diff branch-name # each file one at a time. git difftool -d # See only changes made in the current branch git difftool -d `git merge-base master HEAD` ``` -
akras14 revised this gist
Mar 20, 2015 . 1 changed file with 1 addition and 3 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,9 +127,7 @@ git diff branch-name git difftool -d # See only changes made in current branch git difftool -d `git merge-base master HEAD` ``` ### Working with Remote Branch -
akras14 revised this gist
Mar 20, 2015 . 1 changed file with 5 additions 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 @@ -125,6 +125,11 @@ git diff branch-name # -d tells it to open it in a directory mode, instead of having to open # each file one at a time. git difftool -d # See only changes made in current branch git merge-base master <some-branch> # ^ this command will return a common <common-sha> git difftool -d <common-sha> ``` ### Working with Remote Branch -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 16 additions and 8 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 @@ -48,10 +48,12 @@ git branch -D branchname # See all commits git log # Pretty commit view, you can customize it as much as you want. # Just google it :) git log --pretty=format:"%h %s" --graph # See status of your current git branch. # Often will have advice on command that you need to run git status # Short view of status. Helpful for seeing things at a glance @@ -69,15 +71,18 @@ git add '*.txt' # Tell git not to track file anymore git rm filename # Record changes to git. Default editor will open for a commit message. # (Visible via git log) # Once files are commited, they are history. git commit # A short hand for commiting files and writing a commit message via one command git commit -m 'Some commit message' # Changing the history :) If you want to change your previous commit, # you can, if you haven't pushed it yet to a remote repo # Simply make new changes, add them via git add, and run the following command. # Past commit will be ammended. git commit --amend ``` @@ -124,7 +129,8 @@ git difftool -d ### Working with Remote Branch ```bash # See list of remote repos available. If you did git clone, # you'll have at least one named "origin" git remote # Detailed view of remote repos, with their git urls @@ -133,7 +139,8 @@ git remote -v # Add a new remote. I.e. origin if it is not set git remote add origin <https://some-git-remote-url> # Push current branch to remote branch (usually with the same name) # called upstream branch git push # If a remote branch is not set up as an upstream, you can make it so @@ -143,7 +150,8 @@ git push -u origin master # Otherwise you can manually specify remote and branch to use every time git push origin branchname # Just like pushing, you can get the latest updates from remote. # By defaul Git will try to pull from "origin" and upstream branch git pull # Or you can tell git to pull a specific branch -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 10 additions and 11 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 @@ -165,16 +165,15 @@ git branch -a ### Reference - Try Github - https://try.github.io - lernGitBranching http://pcottle.github.io/learnGitBranching/?NODEMO - Pro Git - Free Book - http://git-scm.com/book ### Viewing History - Source Tree - http://www.sourcetreeapp.com/ - tig - `sudo apt-get install tig` or `brew install tig` etc - gitk - `sudo apt-get install gitk` ### Merge/Diff Tools - Meld - `sudo apt-get install meld` or `brew install meld` - Open Diff - p4v Merge - http://git-scm.com/book/en/Customizing-Git-Git-Configuration#External-Merge-and-Diff-Tools - Webstorm -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 2 additions and 2 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 @@ -163,8 +163,8 @@ git branch -a ``` ## Resources ### Reference - Try Github - https://try.github.io - lernGitBranching http://pcottle.github.io/learnGitBranching/?NODEMO Pro Git http://git-scm.com/book ### Viewing History Source Tree -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 11 additions and 2 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 @@ -106,11 +106,20 @@ git checkout filename **Comparing changes** ``` bash # See current changes, that have not been stage yet. # Good thing to check before running git add git diff # See current changes, that have not been commited yet (including staged changes) git diff HEAD # Compare current branch to some other branch git diff branch-name # Same as diff, but opens changes via difftool that you have configured # -d tells it to open it in a directory mode, instead of having to open # each file one at a time. git difftool -d ``` ### Working with Remote Branch -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 2 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 @@ -104,7 +104,8 @@ git stash pop git checkout filename ``` **Comparing changes** ``` bash git diff git diff HEAD git diff branch name -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 34 additions and 7 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 @@ -113,17 +113,44 @@ git tag ``` ### Working with Remote Branch ```bash # See list of remote repos available. If you did git clone, you'll have at least one named "origin" git remote # Detailed view of remote repos, with their git urls git remote -v # Add a new remote. I.e. origin if it is not set git remote add origin <https://some-git-remote-url> # Push current branch to remote branch (usually with the same name) called upstream branch git push # If a remote branch is not set up as an upstream, you can make it so # The -u tells Git to remember the parameters git push -u origin master # Otherwise you can manually specify remote and branch to use every time git push origin branchname # Just like pushing, you can get the latest updates from remote. By defaul Git will try to pull from "origin" and upstream branch git pull # Or you can tell git to pull a specific branch git pull origin branchname # Git pull, is actually a short hand for two command. # Telling git to first fetch changes from a remote branch # And then to merge them into current branch git fetch && git merge origin/remote-branch-name # If you want to update history of remote branches, you can fetch and purge git fetch -p # To see the list of remote branches # -a stands for all git branch -a ``` ## Resources ### Reference Try Github -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 14 additions and 3 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 @@ -83,14 +83,25 @@ git commit --amend **Advanced** ```bash # Unstage pending changes, the changes will still remain on file system git reset # Unstage pending changes, and reset files to pre-commit state. If git reset --hard HEAD # Go back to some time in history, on the current branch git reset tag git reset <commit-hash> # Save current changes, without having to commit them to repo git stash # And lated return those changes git stash pop # Return file to it's previous version, if it haven't been stage yet. # Otherwise use git reset filename or git reset --hard filename git checkout filename ``` ``` -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 15 additions and 7 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 @@ -44,7 +44,7 @@ git branch -D branchname #### Updating Current Branch **Standard Flow** ```bash # See all commits git log @@ -57,19 +57,27 @@ git status # Short view of status. Helpful for seeing things at a glance git status -s # Add modified file to be commited(aka stage the file) git add filename # Add all modifeid files to be commited(aka stage all files) git add . # Add only text files, etc. git add '*.txt' # Tell git not to track file anymore git rm filename # Record changes to git. Default editor will open for a commit message. (Visible via git log) # Once files are commited, they are history. git commit # A short hand for commiting files and writing a commit message via one command git commit -m 'Some commit message' # Changing the history :) If you want to change your previous commit, you can, if you haven't pushed it yet to a remote repo # Simply make new changes, add them via git add, and run the following command. Past commit will be ammended. git commit --amend ``` -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 14 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 @@ -45,15 +45,25 @@ git branch -D branchname **Standard Flow** ``` # See all commits git log # Pretty commit view, you can customize it as much as you want. Just google it. git log --pretty=format:"%h %s" --graph # See status of your current git branch. Often will have advice on command that you need to run git status # Short view of status. Helpful for seeing things at a glance git status -s # Add modified file to be commited git add filename # Add all modifeid files to be commited git add . # Add only text files, etc. git add '*.txt' git rm git rm filename @@ -63,7 +73,7 @@ git commit -m git commit --amend ``` **Advanced** ```bash git reset git reset -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 2 additions and 2 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 @@ -41,9 +41,9 @@ git branch -d branchname git branch -D branchname ``` #### Updating Current Branch **Standard Flow** ``` git log git log -
akras14 revised this gist
Feb 14, 2015 . 1 changed file with 15 additions and 3 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 @@ -21,14 +21,26 @@ git config --global diff.tool meld ``` ### Working with Local Branch #### Branching ```bash # See the list of all local branches git branch # Switch to existing local branch git checkout branchname # Checkout current branch into a new branch, named new-branch-name git chekcout -b new-branch-name # Merge branch-name into the current branch git merge branchname # Soft branch delete, will complain if the branch is not merged git branch -d branchname # Hard branch delete, will not complain about nothing. Like rm -rf in bash git branch -D branchname ``` Updating Current Branch Standard Flow
NewerOlder