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:
- 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.
- 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.
- Copy this huge line to clipboard.
- Finally, generate the archive:
git archive --format=zip HEAD __PASTE_HERE__ > out.zip
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.