free hit counter

Thursday, December 08, 2011

awk magic for git add

I'm a huge believer in carefully grouping files for commits.  This was altogether intuitive back in my TortoiseSVN days, but with command line git I'm finding awk is useful and more fun.

This command finds all the modified CMakelists.txt files and adds just them:


git status -s | egrep '^ M' | awk '/.txt/ {print $2}' | xargs git add

There's probably a less verbose way to make it happen, but I was surprised how little time it took to construct this command.

0 Comments:

Post a Comment

<< Home