July 2008 Archives

Here's a nice trick to use when you need to do a selective commit in you version control system. Say you have 100's of files in different directories that have been changed, but you only want to commit a certain subset of those. This tip is especially useful if those files can be selected using shell commands.


1 svn st | grep \.install$ | cut -c 8- | xargs svn commit -m "Commit message."
2          # select files
3                           # Remove the status indicators
4                                        # Pass the resulting filenames  to svn commit

This particular command is selecting only files that end in ".install". You could use another argument to grep or other shell mechanisms in place of that.

The real trick here is the use of cut -c 8-, which chops off the first 7 characters (where svn st shows status information), and xargs, which reformats the line-delimited output of svn st and turns it into an argument list.

Who's this guy?

Aaron Longwell is Chief Web Craftsman at New Media Logic Corporation in Coeur d' Alene, Idaho. As a professional software developer for 12 years and a student of public policy, he occasionally has interesting things to say about software, technology, culture and politics.

Subscribe to feed Subscribe to my RSS Feed

  • View Aaron Longwell's profile on LinkedIn
  • Recommend Me