Rip's Domain

The return of BASH Friday!!!!

Posted in Uncategorized by rip747 on July 31, 2009

Quote:

Posted in Quotes by rip747 on July 30, 2009

That it why i keep rabid ferret in my desk. I find people more responsive to my demands once they meet. Go fig.

Export files from a revision or range of revisions with Git

Posted in Git by rip747 on July 29, 2009

If there is one thing I miss about using TortoiseSVN was the convinence of exporting a group of files from a revision or range of revisions. Currently I know of no way of doing this in Git, so I decided to roll my own Git alias to accomplish this.

The alias below takes two arguments:

  1. the revision or range of revision you want to export files from
  2. the directory you want to place them in

So if you want to export all the changed files from HEAD to HEAD~2 and put them in the /cygdrive/c/temp directory, you would do:

$ git exportfiles HEAD..HEAD~2 '/cygdrive/c/temp'

The code is below:

exportfiles = !sh -c 'git diff $0 --name-only | "while read files; do mkdir -p \"$1/$(dirname $files)\"; cp -vf $files $1/$(dirname $files); done"'

Just cut and paste it into the [alias] portion of you .git/config file and you’re ready to go.

As always, if you have a better solution, please leave it in the comments below.