Git Notes
defunkt/hub - Command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier.
-
-
-
-
github/GitPad - EXE to make Notepad the Git editor (commits, interactive rebase, etc).
-
-
git diff < diff of what is changed but not staged
git diff --staged < diff of what is staged but not committed
git diff HEAD < diff of the current state of the files as compared against the most recent commit
git show <hash> < diff of a specific commit
git log origin/master..master < lists unpushed commits
git log origin/master..master --oneline
git commit --amend < change last commit message
git rebase -i < choose and mark the commit to "reword"
git reset --hard HEAD < Restore working to last committed state
git reset --hard < same
git reset --hard MYTAG < Restore working to MYTAG tag reference point
git log --stat -M < shows "renames" instead of deletes and adds
git log --stat -C -C < shows "copies" if that's likely what happened
git log --stat --find-copies-harder < same
git log -- deletedFile.txt < find a deleted file in log history
git add -u . < Add tracked files in the staging area rather than the working tree
git add -A . < Add files in the working tree in addition to the staging area
git add --all . < same
git fetch < retrieval without merging to work in progress
git merge < merges what has been fetched in to working files
git pull < retrieval with merge into work in progress
git log --graph --pretty=oneline --abbrev-commit --decorate --all -5
git branch < local branches
git branch -r < local remote branches
git branch -a < local and local remote branches
git ls-remote origin < remote branches
git ls-remote < same
git branch <branchname> < create new local branch <branchname>
git checkout <branchname> < switch to local branch <branchname>
git checkout -b <branchname> < create and switch to new local branch <branchname>
git push -u origin <branchname> < publishes local branch to remote origin
git checkout master
git merge <branchname> < merges local branch to checked out branch (master in this case)
git stash < push onto a local stash stack
git stash pop < pop the local stash stack
git stash apply < same
git stash branch <branchname> < create branch <branchname> from top of local stash stack
git branch <branchname> THETAGNAME < create branch <branchname> from tag THETAGNAME
git config --get-regexp alias < list aliases
Alias examples:
git config --global alias.aliases "config --get-regexp 'alias.*'"
git config --global alias.s "status -u -s"
git config --global alias.logfive "log --graph --pretty=oneline --abbrev-commit --decorate --all -5"
[alias]
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
aliases = config --get-regexp \"alias.*\"
unpushed-commits = log origin/master..master --date=\"local\" --pretty=format:\"%H %cd - %s\"
statii = "!f() { echo \"Unpushed Commits:\"; echo; git unpushed-commits; echo; echo \"Status of Tracked Files:\"; echo; git status -uno; }; f"
unpushed = "!f() { git log origin/$1..$1 --date=\"local\" --pretty=format:\"%H %cd - %s\"; }; f"
pullr = "!f() { echo \"Stashing uncommitted work...\"; echo; git stash clear; git stash; echo; echo \"Pulling latest changes with rebase...\"; echo; git pull --rebase; echo; echo \"Applying previously stashed work...\"; echo; git stash apply; }; f"