Blog Splash

git: Archiving Files Changed Between Two Revisions

by Kerido Monday, January 18, 2010 8:48 AM

Just recently I started using git and I'm pretty excited about it. Today I needed to obtain a ZIP archive containing only files that were changed or added between a known revision and the current head (I believe, that's roughly the same as trunk in SVN). The solution I came upon is not fully automated, but it's still a HUGE time saver:

  1. Obtain a list of edited files:
    git diff --name-only HEAD __TAG_OR_REVISION__ > out.txt
    After running this command the file out.txt will contain the list of modified file names (including deleted ones), one per line.
  2. Open the out.txt file in a text editor and merge the contents into one line (i.e. replace CR/LF with a space). I also had to manually remove a few files which I didn't need for the archive.
  3. Copy this huge line to clipboard.
  4. Finally, generate the archive:
    git archive --format=zip HEAD __PASTE_HERE__ >

I'm not a command line expert and I'd love to know a better way. I'm sure it's possible on Linux, but I primarily use Windows, so it might take a cmd.exe geek to sort things out.