Skip to content

Instantly share code, notes, and snippets.

@gerardo-orozco
Forked from hofmannsven/README.md
Last active August 29, 2015 14:06
Show Gist options
  • Save gerardo-orozco/d4cf9684cf60598c5b36 to your computer and use it in GitHub Desktop.
Save gerardo-orozco/d4cf9684cf60598c5b36 to your computer and use it in GitHub Desktop.

Revisions

  1. Gerard Orozco renamed this gist Oct 28, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Gerard Orozco renamed this gist Oct 28, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @hofmannsven hofmannsven revised this gist Sep 10, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -318,6 +318,9 @@ Show remote details:
    Add remote origin from GitHub:
    `git remote add origin https://github.com/user/project.git`

    Add remote origin from server:
    `git remote add origin ssh://[email protected]/path/to/repository/.git`

    Remove origin:
    `git remote rm origin`

  4. @hofmannsven hofmannsven revised this gist Jul 8, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -152,9 +152,12 @@ Merge to master (only if fast forward):
    Merge to master (forc a new commit):
    `git merge --no-ff branchname`

    Abort merge:
    Stop merge (in case of conflicts):
    `git merge --abort`

    Stop merge (in case of conflicts):
    `git reset --merge` // prior to v1.7.4


    Stash
    -----------
  5. @hofmannsven hofmannsven revised this gist May 13, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -336,6 +336,12 @@ Push to default:
    Fetch:
    `git fetch origin`

    Pull:
    `git pull`

    Pull specific branch:
    `git pull origin branchname`

    Merge fetched commits:
    `git merge origin/master`

  6. @hofmannsven hofmannsven revised this gist Feb 27, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -346,6 +346,9 @@ Clone to localhost:
    Clone to localhost folder:
    `git clone https://github.com/user/project.git ~/dir/folder`

    Clone specific branch to localhost:
    `git clone -b branchname https://github.com/user/project.git`

    Delete remote branch (push nothing):
    `git push origin :branchname` or:
    `git push origin --delete branchname`
  7. @hofmannsven hofmannsven revised this gist Feb 3, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,9 @@ Global Settings

    Related Setup: https://gist.github.com/hofmannsven/6814278

    Interactive Tutorial: http://try.github.io/
    Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/

    Interactive Beginners Tutorial: http://try.github.io/


    Reminder
  8. @hofmannsven hofmannsven revised this gist Jan 27, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -344,6 +344,6 @@ Clone to localhost:
    Clone to localhost folder:
    `git clone https://github.com/user/project.git ~/dir/folder`

    Relete remote branch (push nothing):
    Delete remote branch (push nothing):
    `git push origin :branchname` or:
    `git push origin --delete branchname`
  9. @hofmannsven hofmannsven revised this gist Jan 8, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -288,9 +288,15 @@ Releases & Version Tags
    Show all released versions:
    `git tag`

    Show all released versions with comments:
    `git tag -l -n1`

    Create release version:
    `git tag v1.0`

    Create release version with comment:
    `git tag -a v1.0 -m 'Message'`

    Checkout a specific release version:
    `git checkout v1.0`

  10. @hofmannsven hofmannsven revised this gist Dec 8, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -282,6 +282,19 @@ Useful comparings:
    `git diff --stat --summary 6eb715d..HEAD`


    Releases & Version Tags
    -----------

    Show all released versions:
    `git tag`

    Create release version:
    `git tag v1.0`

    Checkout a specific release version:
    `git checkout v1.0`


    Collaborate
    -----------

  11. @hofmannsven hofmannsven revised this gist Oct 16, 2013. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,6 @@ Press `minus + shift + s` and `return` to chop/fold long lines!

    Show folder content: `ls -la`

    Go straight to MAMP/htdocs: `cd /Applications/MAMP/htdocs`


    Setup
    -----------
  12. @hofmannsven hofmannsven revised this gist Oct 13, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@ Global Settings

    Related Setup: https://gist.github.com/hofmannsven/6814278

    Interactive Tutorial: http://try.github.io/


    Reminder
    -----------
  13. @hofmannsven hofmannsven revised this gist Oct 7, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,9 @@ Add and commit in one step:
    Remove files from Git:
    `git rm index.html`

    Update all changes:
    `git add -u`

    Kepp file but do not track anymore:
    `git rm --cached index.html`

  14. @hofmannsven hofmannsven revised this gist Oct 4, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -316,7 +316,8 @@ Merge fetched commits:
    `git merge origin/master`

    Clone to localhost:
    `git clone https://github.com/user/project.git`
    `git clone https://github.com/user/project.git` or:
    `git clone ssh://[email protected]/~/dir/.git`

    Clone to localhost folder:
    `git clone https://github.com/user/project.git ~/dir/folder`
  15. @hofmannsven hofmannsven revised this gist Oct 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -319,7 +319,7 @@ Clone to localhost:
    `git clone https://github.com/user/project.git`

    Clone to localhost folder:
    `git clone https://github.com/user/project.git dir/folder`
    `git clone https://github.com/user/project.git ~/dir/folder`

    Relete remote branch (push nothing):
    `git push origin :branchname` or:
  16. @hofmannsven hofmannsven revised this gist Oct 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -289,7 +289,7 @@ Show remote details:
    `git remote -v`

    Add remote origin from GitHub:
    `git remode add origin https://github.com/user/project.git`
    `git remote add origin https://github.com/user/project.git`

    Remove origin:
    `git remote rm origin`
  17. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ Press `minus + shift + s` and `return` to chop/fold long lines!

    Show folder content: `ls -la`

    Go straight to MAMP/htdocs: `cd /Applications/MAMP/htdocs/`
    Go straight to MAMP/htdocs: `cd /Applications/MAMP/htdocs`


    Setup
  18. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,16 @@ Global Settings
    Related Setup: https://gist.github.com/hofmannsven/6814278


    Reminder
    -----------

    Press `minus + shift + s` and `return` to chop/fold long lines!

    Show folder content: `ls -la`

    Go straight to MAMP/htdocs: `cd /Applications/MAMP/htdocs/`


    Setup
    -----------

    @@ -48,13 +58,16 @@ Add and commit in one step:
    Remove files from Git:
    `git rm index.html`

    Kepp file but do not track anymore:
    `git rm --cached index.html`

    Move or rename files:
    `git mv index.html dir/index_new.html`

    Undo modifications (restore files from latest commited version):
    `git checkout -- index.html`

    Restore file from a custom commit:
    Restore file from a custom commit (in current branch):
    `git checkout 6eb715d -- index.html`


    @@ -169,6 +182,10 @@ Delete complete stash:
    Gitignore & Gitkeep
    -----------

    About: https://help.github.com/articles/ignoring-files

    Useful templates: https://github.com/github/gitignore

    Add or edit gitignore:
    `nano .gitignore`

  19. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 37 additions and 3 deletions.
    40 changes: 37 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -58,7 +58,41 @@ Restore file from a custom commit:
    `git checkout 6eb715d -- index.html`


    Branching
    Reset
    -----------

    Go back to commit:
    `git revert 073791e7dd71b90daa853b2c5acc2c925f02dbc6`

    Soft reset (move HEAD only; neither staging nor working dir is changed):
    `git reset --soft 073791e7dd71b90daa853b2c5acc2c925f02dbc6`

    Mixed reset (move HEAD and change staging to match repo; does not affect working dir):
    `git reset --mixed 073791e7dd71b90daa853b2c5acc2c925f02dbc6`

    Hard reset (move HEAD and change staging dir and working dir to match repo):
    `git reset --hard 073791e7dd71b90daa853b2c5acc2c925f02dbc6`

    Update & Delete
    -----------

    Test-Delete untracked files:
    `git clean -n`

    Delete untracked files (not staging):
    `git clean -f`

    Unstage (undo adds):
    `git reset HEAD index.html`

    Commit to most recent commit:
    `git commit --amend -m "Message"`

    Update most recent commit message:
    `git commit --amend -m "New Message"`


    Branch
    -----------

    Show branches:
    @@ -104,7 +138,7 @@ Abort merge:
    `git merge --abort`


    Stashing
    Stash
    -----------

    Put in stash:
    @@ -189,7 +223,7 @@ Show history of commits as graph-summary:
    `git log --oneline --graph --all --decorate`


    Compare versions
    Compare
    -----------

    Compare modified files:
  20. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 38 additions and 1 deletion.
    39 changes: 38 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Using Git
    Global Settings
    -----------

    Related Intro: https://gist.github.com/hofmannsven/6814278
    Related Setup: https://gist.github.com/hofmannsven/6814278


    Setup
    @@ -77,6 +77,9 @@ Rename branch:
    `git branch -m branchname new_branchname` or:
    `git branch --move branchname new_branchname`

    Show all completely merged branches with current branch:
    `git branch --merged`

    Delete merged branch (only possible if not HEAD):
    `git branch -d branchname` or:
    `git branch --delete branchname`
    @@ -101,6 +104,34 @@ Abort merge:
    `git merge --abort`


    Stashing
    -----------

    Put in stash:
    `git stash save "Message"`

    Show stash:
    `git stash list`

    Show stash stats:
    `git stash show stash@{0}`

    Show stash changes:
    `git stash show -p stash@{0}`

    Use custom stash item and drop it:
    `git stash pop stash@{0}`

    Use custom stash item and do not drop it:
    `git stash apply stash@{0}`

    Delete custom stash item:
    `git stash drop stash@{0}`

    Delete complete stash:
    `git stash clear`


    Gitignore & Gitkeep
    -----------

    @@ -170,6 +201,12 @@ Compare modified files and highlight changes only:
    Compare modified files within the staging area:
    `git diff --staged`

    Compare branches:
    `git diff master..branchname`

    Compare branches like above:
    `git diff --color-words master..branchname^`

    Compare commits:
    `git diff 6eb715d`
    `git diff 6eb715d..HEAD`
  21. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 48 additions and 1 deletion.
    49 changes: 48 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Using Git
    Global Settings
    -----------

    Related Tutorial: https://gist.github.com/hofmannsven/6814278
    Related Intro: https://gist.github.com/hofmannsven/6814278


    Setup
    @@ -189,3 +189,50 @@ Compare without caring about all spaces:

    Useful comparings:
    `git diff --stat --summary 6eb715d..HEAD`


    Collaborate
    -----------

    Show remote:
    `git remote`

    Show remote details:
    `git remote -v`

    Add remote origin from GitHub:
    `git remode add origin https://github.com/user/project.git`

    Remove origin:
    `git remote rm origin`

    Show remote branches:
    `git branch -r`

    Show all branches:
    `git branch -a`

    Compare:
    `git diff origin/master..master`

    Push (set default with `-u`):
    `git push -u origin master`

    Push to default:
    `git push origin master`

    Fetch:
    `git fetch origin`

    Merge fetched commits:
    `git merge origin/master`

    Clone to localhost:
    `git clone https://github.com/user/project.git`

    Clone to localhost folder:
    `git clone https://github.com/user/project.git dir/folder`

    Relete remote branch (push nothing):
    `git push origin :branchname` or:
    `git push origin --delete branchname`
  22. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 87 additions and 4 deletions.
    91 changes: 87 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -45,6 +45,72 @@ Commit changes:
    Add and commit in one step:
    `git commit -am "Message"`

    Remove files from Git:
    `git rm index.html`

    Move or rename files:
    `git mv index.html dir/index_new.html`

    Undo modifications (restore files from latest commited version):
    `git checkout -- index.html`

    Restore file from a custom commit:
    `git checkout 6eb715d -- index.html`


    Branching
    -----------

    Show branches:
    `git branch`

    Create branch:
    `git branch branchname`

    Change to branch:
    `git checkout branchname`

    Create and change to new branch:
    `git checkout -b branchname`

    Rename branch:
    `git branch -m branchname new_branchname` or:
    `git branch --move branchname new_branchname`

    Delete merged branch (only possible if not HEAD):
    `git branch -d branchname` or:
    `git branch --delete branchname`

    Delete not merged branch:
    `git branch -D branch_to_delete`


    Merge
    -----------

    True merge (fast forward):
    `git merge branchname`

    Merge to master (only if fast forward):
    `git merge --ff-only branchname`

    Merge to master (forc a new commit):
    `git merge --no-ff branchname`

    Abort merge:
    `git merge --abort`


    Gitignore & Gitkeep
    -----------

    Add or edit gitignore:
    `nano .gitignore`

    Track empty dir:
    `touch dir/.gitkeep`


    Log
    -----------

    @@ -91,6 +157,10 @@ Show history of commits as graph:
    Show history of commits as graph-summary:
    `git log --oneline --graph --all --decorate`


    Compare versions
    -----------

    Compare modified files:
    `git diff`

    @@ -100,9 +170,22 @@ Compare modified files and highlight changes only:
    Compare modified files within the staging area:
    `git diff --staged`

    Remove files from Git:
    `git rm index.html`
    Compare commits:
    `git diff 6eb715d`
    `git diff 6eb715d..HEAD`
    `git diff 6eb715d..537a09f`

    Move or rename files:
    `git mv index.html dir/index_new.html`
    Compare commits of file:
    `git diff 6eb715d index.html`
    `git diff 6eb715d..537a09f index.html`

    Compare without caring about spaces:
    `git diff -b 6eb715d..HEAD` or:
    `git diff --ignore-space-change 6eb715d..HEAD`

    Compare without caring about all spaces:
    `git diff -w 6eb715d..HEAD` or:
    `git diff --ignore-all-space 6eb715d..HEAD`

    Useful comparings:
    `git diff --stat --summary 6eb715d..HEAD`
  23. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 74 additions and 5 deletions.
    79 changes: 74 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,25 @@
    Using Git
    ===============

    Setup
    Global Settings
    -----------

    Create an alias (shortcut) for `git status`:
    `git config --global alias.st status`
    Related Tutorial: https://gist.github.com/hofmannsven/6814278


    Setup
    -----------

    See where Git is located:
    `which git`

    Get the version of Git:
    `git --version`

    Create an alias (shortcut) for `git status`:
    `git config --global alias.st status`


    Help
    -----------

    @@ -30,10 +37,72 @@ Get verything ready to commit:
    `git add .`

    Get custom file ready to commit:
    `git add filename.txt`
    `git add index.html`

    Commit changes:
    `git commit -m "Message"`

    Add and commit in one step:
    `git commit -am "Message"`
    `git commit -am "Message"`

    Log
    -----------

    Show commits:
    `git log`

    Show oneline-summary of commits:
    `git log --oneline`

    Show oneline-summary of commits with full SHA-1:
    `git log --format=oneline`

    Show oneline-summary of the last three commits:
    `git log --oneline -3`

    Show only custom commits:
    `git log --author="Sven"`
    `git log --grep="Message"`
    `git log --until=2013-01-01`
    `git log --since=2013-01-01`

    Show only custom data of commit:
    `git log --format=short`
    `git log --format=full`
    `git log --format=fuller`
    `git log --format=email`
    `git log --format=raw`

    Show changes:
    `git log -p`

    Show every commit since special commit for custom file only:
    `git log 6eb715d.. index.html`

    Show changes of every commit since special commit for custom file only:
    `git log -p 6eb715d.. index.html`

    Show stats and summary of commits:
    `git log --stat --summary`

    Show history of commits as graph:
    `git log --graph`

    Show history of commits as graph-summary:
    `git log --oneline --graph --all --decorate`

    Compare modified files:
    `git diff`

    Compare modified files and highlight changes only:
    `git diff --color-words index.html`

    Compare modified files within the staging area:
    `git diff --staged`

    Remove files from Git:
    `git rm index.html`

    Move or rename files:
    `git mv index.html dir/index_new.html`

  24. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 3 changed files with 32 additions and 16 deletions.
    33 changes: 32 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,39 @@
    Using Git
    ===============

    Setup
    -----------

    Create an alias (shortcut) for `git status`:
    `git config --global alias.st status`

    See where Git is located:
    `which git`

    Get the version of Git:
    `git --version`

    Help
    -----------

    Help:
    `git help`
    `git help`


    General
    -----------

    Initialize Git:
    `git init`

    Get verything ready to commit:
    `git add .`

    Get custom file ready to commit:
    `git add filename.txt`

    Commit changes:
    `git commit -m "Message"`

    Add and commit in one step:
    `git commit -am "Message"`
    9 changes: 0 additions & 9 deletions cheatsheet
    Original file line number Diff line number Diff line change
    @@ -1,9 +0,0 @@
    Initialize Git:
    `git init`

    Get verything ready to commit:
    `git add .`

    Get custom file ready to commit:

    `git add filename.txt`
    6 changes: 0 additions & 6 deletions global
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    See where Git is located:
    `which git`

    Get the version of Git:
    `git --version`

  25. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 3 changed files with 20 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    Using Git
    ===============

    See where Git is located:
    `which git`
    Create an alias (shortcut) for `git status`:
    `git config --global alias.st status`

    Help:
    `git help`
    9 changes: 9 additions & 0 deletions cheatsheet
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    Initialize Git:
    `git init`

    Get verything ready to commit:
    `git add .`

    Get custom file ready to commit:

    `git add filename.txt`
    6 changes: 6 additions & 0 deletions global
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    See where Git is located:
    `which git`

    Get the version of Git:
    `git --version`

  26. @hofmannsven hofmannsven revised this gist Oct 3, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    Using Git
    ===============

    `asd`
    See where Git is located:
    `which git`
  27. @hofmannsven hofmannsven created this gist Oct 3, 2013.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    Using Git
    ===============

    `asd`