Thursday, April 19, 2012

find and replace in place

With our current project structure we are constantly having to jump across versions. Simplest way for in place replacement.

For e.g. to find and replace all snapshot versions in pom.xml

find . -name 'pom.xml' -print0 | xargs -0 sed -i 's/3.1.0-SNAPSHOT/3.1.4-SNAPSHOT/g'

or

find . -name 'pom.xml' -exec sed -i 's/3.1.4-SNAPSHOT/3.1.5-SNAP/g' {} \;

Friday, March 30, 2012

Git log

while git log is standard, quite often I found the need to have a stripped down version of the logs. Git alias to the rescue again

This gives you a one line representation of the hash tag, the author and message

vi ~/.gitconfig
[alias]
lg = log --pretty=format:'%Cred%h %Cblue%an:%Creset%s'

If you want the entire history this works great
lgall = log --graph --oneline --decorate --all

Thursday, March 29, 2012

git remove untracked files

I do a lot of branch switching and files which are ignored in one branch show up as untracked files. This gets annoying during merge conflicts as then its difficult to keep track of whats actually conflicted and new and whats not.

After trying around a few commands this alias works great for me

vi ~/.gitconfig

[alias]
remove-untracked = "!git ls-files --other --exclude-standard | xargs rm;"


Now just run git remove-untracked and the eyesore is gone!