Skip to content

Instantly share code, notes, and snippets.

@raineorshine
Last active December 22, 2023 15:59
Show Gist options
  • Select an option

  • Save raineorshine/5128563 to your computer and use it in GitHub Desktop.

Select an option

Save raineorshine/5128563 to your computer and use it in GitHub Desktop.

Revisions

  1. raineorshine revised this gist Dec 22, 2023. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -46,24 +46,26 @@ git diff --word-diff
    git diff --staged # show the changes that have been staged
    git diff 0c6de32 HEAD # compare the current commit to a previous commit

    # bisect
    git bisect start # enter bisect mode
    git bisect good # mark current commit as bad
    git bisect bad # mark the current commit as good
    git bisect log # show the good/bad commits
    git bisect reset # exit bisect mode and return to the original commit

    # reset
    git reset <FILE_OR_DIRECTORY> # unstage
    git checkout -- <FILE> # throw away local modifications and reset to last committed version of given file
    git checkout 0c6de32 # browse a previous commit in detached HEAD state. git checkout master to reattach.
    git checkout 0c6de32 # browse a commit in detached HEAD state. git checkout <BRANCH> to reattach
    git checkout HEAD~ # checkout previous commit in detached HEAD state
    git reset --hard HEAD # throw away local modifications and reset to latest of current branch
    git reset --hard 0c6de32 # throw away local modifications and reset to specific commit
    git clean -f # remove untracked files
    git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that
    # has already been pushed to a remote.

    git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index
    # *these are useful if you forgot to create a .gitignore before adding files*

    # checkout prev (older) revision
    git_prev() {
    git checkout HEAD~
    }
    git rm FILE # Remove a file from the index. Useful if it was not gitignored.
    git rm -r FOLDER # Remove a folder from the index. Useful if it was not gitignored.

    # checkout next (newer) commit
    git_next() {
  2. raineorshine revised this gist Dec 22, 2023. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,14 @@ git checkout -b <MYBRANCH> # create and checkout a new branch
    git branch -d <MYBRANCH> # delete a local branch
    git branch -m <MYBRANCH> # rename the current branch
    git checkout --track origin/<MYBRANCH> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge <MYBRANCH> # merge the commits from the given branch into the current branch
    git merge <MYBRANCH> # merge the commits from the given branch into the current branch

    # cloning
    git clone <URL> # clone full history
    git clone <URL> <DIR> # clone full history and rename directory
    git clone --depth=1 <URL> # clone shallow
    git fetch --unshallow # fetch all remote branches despite shallow clone
    git remote set-branches --add origin dev # allow set-upstream from shallow clone

    # tagging
    git tag # list available tags
  3. raineorshine revised this gist Dec 18, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ git fetch # gets remote objects and refs. Needed if new
    git remote -v # Lists all remotes (verbose)
    git pull origin master # Pulls commits from the 'origin' remote's master branch and stores them in the local repo
    git push -u origin master # sets ups tracking so that you can 'git push' without extra args
    git push them branch:theirbranch # Push to a contributor branch that has enabled owner edits
    git show :/^Merge # show the last commit whose message matches a regex

    # branches - creating, checking out, and merging
  4. raineorshine revised this gist Apr 19, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -52,13 +52,13 @@ git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index
    # *these are useful if you forgot to create a .gitignore before adding files*

    # checkout next revision
    git_next() {
    # checkout prev (older) revision
    git_prev() {
    git checkout HEAD~
    }

    # checkout prev commit
    git_prev() {
    # checkout next (newer) commit
    git_next() {
    BRANCH=`git show-ref | grep $(git show-ref -s -- HEAD) | sed 's|.*/\(.*\)|\1|' | grep -v HEAD | sort | uniq`
    HASH=`git rev-parse $BRANCH`
    PREV=`git rev-list --topo-order HEAD..$HASH | tail -1`
  5. raineorshine revised this gist Apr 19, 2014. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -52,6 +52,19 @@ git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index
    # *these are useful if you forgot to create a .gitignore before adding files*

    # checkout next revision
    git_next() {
    git checkout HEAD~
    }

    # checkout prev commit
    git_prev() {
    BRANCH=`git show-ref | grep $(git show-ref -s -- HEAD) | sed 's|.*/\(.*\)|\1|' | grep -v HEAD | sort | uniq`
    HASH=`git rev-parse $BRANCH`
    PREV=`git rev-list --topo-order HEAD..$HASH | tail -1`
    git checkout $PREV
    }

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
    cd <old repo>
  6. raineorshine revised this gist Apr 19, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -36,10 +36,12 @@ git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%a
    # diff
    git diff --word-diff
    git diff --staged # show the changes that have been staged
    git diff 0c6de32 HEAD # compare the current commit to a previous commit

    # reset
    git reset <FILE_OR_DIRECTORY> # unstage
    git checkout -- <FILE> # throw away local modifications and reset to last committed version of given file
    git checkout 0c6de32 # browse a previous commit in detached HEAD state. git checkout master to reattach.
    git reset --hard HEAD # throw away local modifications and reset to latest of current branch
    git reset --hard 0c6de32 # throw away local modifications and reset to specific commit
    git clean -f # remove untracked files
  7. raineorshine revised this gist Apr 18, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,7 @@ curl -u '<username>' https://api.github.com/user/repos -d '{"name":"<new repo>"}
    git remote add origin <new repo>
    git push origin master

    # display branches sorted by date
    git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate) %(authorname) %(refname:short)'

    # Other Awesomeness: http://hub.github.com
  8. raineorshine revised this gist Feb 23, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,7 @@ git revert HEAD # Make a commit that undoes the last commit. U

    git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index
    # *these are useful if you forgot to create a .gitignore before adding files*

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
  9. raineorshine revised this gist Jan 25, 2014. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    # adding and committing
    git add -A # stages All
    git add . # stages new and modified, without deleted
    git add -u # stages modified and deleted, without new
    git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
    git commit --amend --no-edit # Do so without having to edit the commit message.

    # remotes - pushing, pulling, and tracking
    git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
    git remote -v # Lists all remotes (verbose)
    @@ -38,8 +45,6 @@ git reset --hard 0c6de32 # throw away local modifications and reset to
    git clean -f # remove untracked files
    git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that
    # has already been pushed to a remote.
    git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
    git commit --amend --no-edit # Do so without having to edit the commit message.

    git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index
  10. @metaraine metaraine revised this gist Oct 6, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -52,4 +52,6 @@ git filter-branch --subdirectory-filter <new repo> -- --all
    cd <new repo>
    curl -u '<username>' https://api.github.com/user/repos -d '{"name":"<new repo>"}'
    git remote add origin <new repo>
    git push origin master
    git push origin master

    # Other Awesomeness: http://hub.github.com
  11. @metaraine metaraine revised this gist Oct 6, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,9 @@ git revert HEAD # Make a commit that undoes the last commit. U
    git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
    git commit --amend --no-edit # Do so without having to edit the commit message.

    git rm FILE # Remove a file from the index
    git rm -r FOLDER # Remove a folder from the index

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
    cd <old repo>
  12. @metaraine metaraine revised this gist Sep 16, 2013. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,13 @@ git show :/^Merge # show the last commit whose message matches a
    # branches - creating, checking out, and merging
    git branch # list branches
    git branch -a # list branches including remotes
    git branch MYBRANCH # Creates a new branch called "MYBRANCH"
    git checkout MYBRANCH # Makes MYBRANCH the active branch
    git checkout -b MYBRANCH # Shortcut to create and checkout a new branch
    git branch <MYBRANCH> # Creates a new branch called "MYBRANCH"
    git checkout <MYBRANCH> # Makes MYBRANCH the active branch
    git checkout -b <MYBRANCH> # create and checkout a new branch
    git branch -d <MYBRANCH> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge <BRANCH_NAME> # merge the commits from the given branch into the current branch
    git branch -m <MYBRANCH> # rename the current branch
    git checkout --track origin/<MYBRANCH> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge <MYBRANCH> # merge the commits from the given branch into the current branch

    # tagging
    git tag # list available tags
    @@ -37,6 +38,8 @@ git reset --hard 0c6de32 # throw away local modifications and reset to
    git clean -f # remove untracked files
    git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that
    # has already been pushed to a remote.
    git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
    git commit --amend --no-edit # Do so without having to edit the commit message.

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
  13. @metaraine metaraine revised this gist Sep 16, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ git checkout MYBRANCH # Makes MYBRANCH the active branch
    git checkout -b MYBRANCH # Shortcut to create and checkout a new branch
    git branch -d <MYBRANCH> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge upstream/master # merge the commits from the given branch into the current branch
    git merge <BRANCH_NAME> # merge the commits from the given branch into the current branch

    # tagging
    git tag # list available tags
    @@ -27,9 +27,11 @@ git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%a

    # diff
    git diff --word-diff
    git diff --staged # show the changes that have been staged

    # reset
    git reset <FILE_OR_DIRECTORY> # unstage
    git checkout -- <FILE> # throw away local modifications and reset to last committed version of given file
    git reset --hard HEAD # throw away local modifications and reset to latest of current branch
    git reset --hard 0c6de32 # throw away local modifications and reset to specific commit
    git clean -f # remove untracked files
  14. @metaraine metaraine revised this gist Sep 12, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # remotes - pushing, pulling, and tracking
    git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
    git remote -v # Lists all remotes
    git pull upstream master # Pulls commits from 'upstream' and stores them in the local repository
    git remote -v # Lists all remotes (verbose)
    git pull origin master # Pulls commits from the 'origin' remote's master branch and stores them in the local repo
    git push -u origin master # sets ups tracking so that you can 'git push' without extra args
    git show :/^Merge # show the last commit whose message matches a regex

    @@ -10,7 +10,7 @@ git branch # list branches
    git branch -a # list branches including remotes
    git branch MYBRANCH # Creates a new branch called "MYBRANCH"
    git checkout MYBRANCH # Makes MYBRANCH the active branch
    git checkout -b MYBRANCH # Shortcut for the last two commands
    git checkout -b MYBRANCH # Shortcut to create and checkout a new branch
    git branch -d <MYBRANCH> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge upstream/master # merge the commits from the given branch into the current branch
  15. @metaraine metaraine revised this gist Sep 12, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ git reset --hard HEAD # throw away local modifications and reset to
    git reset --hard 0c6de32 # throw away local modifications and reset to specific commit
    git clean -f # remove untracked files
    git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that
    # already been pushed to a remote.
    # has already been pushed to a remote.

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
  16. @metaraine metaraine revised this gist Sep 12, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -30,9 +30,11 @@ git diff --word-diff

    # reset
    git reset <FILE_OR_DIRECTORY> # unstage
    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git reset --hard HEAD # throw away local modifications and reset to latest of current branch
    git reset --hard 0c6de32 # throw away local modifications and reset to specific commit
    git clean -f # remove untracked files
    git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that
    # already been pushed to a remote.

    # create a new repo from a directory in an old repo, preserving history
    git clone <old repo>
  17. raineorshine revised this gist Aug 10, 2013. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -35,11 +35,11 @@ git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files

    # create a new repo from a directory in an old repo, preserving history
    1. git clone <old repo>
    2. cd <old repo>
    3. git remote rm origin
    4. git filter-branch --subdirectory-filter <new repo> -- --all
    5. cd <new repo>
    6. curl -u '<username>' https://api.github.com/user/repos -d '{"name":"<new repo>"}'
    7. git remote add origin <new repo>
    8. git push origin master
    git clone <old repo>
    cd <old repo>
    git remote rm origin
    git filter-branch --subdirectory-filter <new repo> -- --all
    cd <new repo>
    curl -u '<username>' https://api.github.com/user/repos -d '{"name":"<new repo>"}'
    git remote add origin <new repo>
    git push origin master
  18. raineorshine revised this gist Aug 10, 2013. 1 changed file with 14 additions and 13 deletions.
    27 changes: 14 additions & 13 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,3 @@
    # tagging
    git tag # list available tags
    git tag -l v1.4.2.* # search for specific tags
    git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag
    git push --tag # you have to explicitly push tags to remotes
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates

    # diff
    git diff --word-diff

    # remotes - pushing, pulling, and tracking
    git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
    git remote -v # Lists all remotes
    @@ -28,7 +15,21 @@ git branch -d <MYBRANCH> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge upstream/master # merge the commits from the given branch into the current branch

    # tagging
    git tag # list available tags
    git tag -l v1.4.2.* # search for specific tags
    git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag
    git push --tag # you have to explicitly push tags to remotes
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates

    # diff
    git diff --word-diff

    # reset
    git reset <FILE_OR_DIRECTORY> # unstage
    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files
  19. raineorshine revised this gist Aug 9, 2013. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -11,15 +11,22 @@ git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%a
    # diff
    git diff --word-diff

    # branches and remotes
    # remotes - pushing, pulling, and tracking
    git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
    git remote -v # Lists all remotes
    git pull upstream master # Pulls commits from 'upstream' and stores them in the local repository
    git push -u origin master # sets ups tracking so that you can 'git push' without extra args
    git show :/^Merge # show the last commit whose message matches a regex

    # branches - creating, checking out, and merging
    git branch # list branches
    git branch -a # list branches including remotes
    git branch -d <BRANCH_NAME> # delete a local branch
    git branch MYBRANCH # Creates a new branch called "MYBRANCH"
    git checkout MYBRANCH # Makes MYBRANCH the active branch
    git checkout -b MYBRANCH # Shortcut for the last two commands
    git branch -d <MYBRANCH> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration
    git merge upstream/master # merge the commits from the given branch into the current branch

    # reset
    git reset --hard HEAD # reset to latest of current branch
  20. raineorshine revised this gist Aug 9, 2013. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -6,17 +6,22 @@ git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag
    git push --tag # you have to explicitly push tags to remotes
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates

    # show tags with creation dates
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'

    # show remotes
    git remote -v

    # diff
    git diff --word-diff

    # branches and remotes
    git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
    git remote -v # Lists all remotes
    git push -u origin master # sets ups tracking so that you can 'git push' without extra args
    git show :/^Merge # show the last commit whose message matches a regex
    git branch # list branches
    git branch -a # list branches including remotes
    git branch -d <BRANCH_NAME> # delete a local branch
    git checkout --track origin/<BRANCH_NAME> # create a new local branch with the same name as the remote and set "upstream" configuration

    # reset
    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files
  21. raineorshine revised this gist Jun 1, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,10 @@ git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%a
    # show remotes
    git remote -v

    git diff --word-diff
    git push -u origin master # sets ups tracking so that you can 'git push' without extra args
    git show :/^Merge # show the last commit whose message matches a regex

    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files
  22. raineorshine revised this gist May 1, 2013. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion cheatsheet-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # tagging
    git tag # list available tags
    git tag -l v1.4.2.* # search for specific tags
    git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    @@ -9,6 +10,19 @@ git push --tag # you have to explicitly push tags to remotes
    # show tags with creation dates
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'

    # show remotes
    git remote -v

    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files
    git clean -f # remove untracked files

    # create a new repo from a directory in an old repo, preserving history
    1. git clone <old repo>
    2. cd <old repo>
    3. git remote rm origin
    4. git filter-branch --subdirectory-filter <new repo> -- --all
    5. cd <new repo>
    6. curl -u '<username>' https://api.github.com/user/repos -d '{"name":"<new repo>"}'
    7. git remote add origin <new repo>
    8. git push origin master
  23. raineorshine renamed this gist Apr 17, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  24. raineorshine revised this gist Apr 17, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cheatsheet-git.bash
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,9 @@ git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag
    git push --tag # you have to explicitly push tags to remotes
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates

    # show tags with creation dates
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'

    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
  25. raineorshine revised this gist Apr 17, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions cheatsheet-git.bash
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@ git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag
    git push --tag # you have to explicitly push tags to remotes
    git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates

    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
  26. raineorshine revised this gist Apr 17, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cheatsheet-git.bash
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    git tag # list available tags
    git tag -l v1.4.2.* # search for specific tags
    git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot)
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag

  27. raineorshine revised this gist Apr 17, 2013. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion cheatsheet-git.bash
    Original file line number Diff line number Diff line change
    @@ -1 +1,9 @@
    git reset --hard 0c6de32
    git tag # list available tags
    git tag -l v1.4.2.* # search for specific tags
    git tag -a v1.4 -m 'version 1.4' # create an annotated tag
    git show v1.4 # show the tag data of a specific tag
    git tag v1.4 # create a lightweight tag

    git reset --hard HEAD # reset to latest of current branch
    git reset --hard 0c6de32 # reset to specific commit
    git clean -f # remove untracked files
  28. raineorshine created this gist Mar 10, 2013.
    1 change: 1 addition & 0 deletions cheatsheet-git.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    git reset --hard 0c6de32