Skip to content

Instantly share code, notes, and snippets.

@johnallen3d
Created June 13, 2012 13:04
Show Gist options
  • Save johnallen3d/2923935 to your computer and use it in GitHub Desktop.
Save johnallen3d/2923935 to your computer and use it in GitHub Desktop.
NOTES: Advanced Git Training by Github.com

General

  • HEAD current commit on current branch

  • git log

    -1 : most recent one (1)

    --stat : shows files changed in commit

    --patch : shows differences in text

    --pretty=oneline : flattens on t one line

    --pretty=raw : more detail on commits (tree etc)

    --graph : shows history graph

  • git commmit --ammend

changes commit history (add changes and/or modify message)

  • git reflog

show full history including rebased, modified, deleted commits etc (60 days)

  • git diff

    --color-words : shows only word changes in different colors --word-diff : makes word diffs machine parsable

  • git reset HEAD@{3}

    --hard : changes current head to back three commits (can lose files) --mixed : changes head, blows away staging (not touching working tree) --soft : changes only head

  • git reset --hard

backs out current changes in working tree

  • git revert [hash]

creates a new commit that removes a prior commit, use after push instead of rebase

  • git ls-tree [hash-index]

show tree of a commit

  • git cat-file -p [hash-index]

pretty print content of commit

  • git config --global alias.lol "log --pretty=oneline --graph"

adds an alias for a one line log with graph (git lol)

  • git rev-parse HEAD

show sha of indicated commit

  • git push --prune

delete all upstream branches that have been deleted locally

##REBASE

  • git rebase -i HEAD~4 OR HEAD^^^^ OR HEAD@{4}

all mean 4 prior to head

  • git commit --ammend

    --ammend : when dropping an edit into a rebase, make changes, add them then ammend

  • git rebase --continue

    --continue : finishes rebase, allows for editing of commit message

  • git pull --rebase

rebases the pull into current branch

  • git config branch.autosetuprebase true

pull now does pull --rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment