Thursday, October 23, 2014

Cool Tools: Git Helpers

This post will enumerate the helpers and commands I use with git, I expect it to refresh as I learn of more. 

This is now basically out of date, and a place to jog my memory. 

I'd recommend finding your problem and solution here:

https://github.com/k88hudson/git-flight-rules
Tools:
Source Tree - a superb gui for git. I use it for all but the simplest commits.
gitk - Built into the git distro, gitk allows you to visualize the tree


Uncommon, but useful operations

Move recent commit from master to a branch.

git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch

Get a local copy of a server branch (tracking branch)  
 git checkout  



See which branches contain which commit

 git branch -r --contains

See pretty view of history (all after tag 1.2.38.0)

git log --decorate --oneline --no-merges  1.2.38.0..

Even prettier

git log --pretty=format:"%C(yellow)%h%Cred%d\ %Creset%s%Cblue\ [%cn]" --decorate

Revert a file on a branch back to the copy in master

git diff ..master -- scorch.bat  > patch
git apply patch

Git touch

 git commit --allow-empty -m "Trigger notification"

No comments: