Saturday, July 23, 2011

Git and windows

I've missed git since joining overstock, so while starting on a new personal project, I decided to start off with git again.

Now it's been a while since I've programmed on Windows and once you're used to 'nix machine you miss all the tools that's built in. After keeping forgetting that ls, vim or ssh won't work on the stupid windows prompt, I was looking at alternatives.

Git Bash is a brilliant tool for anyone using git on bash. One problem is since it doesn't share the same registers with the base windows OS, copy pasting isn't the easiest. However I noticed that Shift-Insert works to solve that problem. Also windows system variables don't get translated well into git bash - I solved it by redefining them in ~/.bash_profile

If you don't have a git config file, I would recommend using git config initially

git config "anoop"
git config ""

Once you execute this in your project, git creates a file called config under the .git directory.
Here are some of my favorite aliases as well to add to that file:

st = status
ci = commit
cia = commit --amend
co = checkout
br = branch
sb = show-branch
cp = cherry-pick
staged = diff --staged
di = diff
rb = rebase
sm = submodule
head = !"git log -n1"
whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1
\"' -" #takes in name of person or email address
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short #takes in comm
it name
edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; vim
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git
add `f`"
lg = log --graph --oneline --decorate --all

No comments: