1

I have 1000+ XML versioned in git, I wrote a script to parse and work on the XML data. During this year the content of the XMLs was changed and committed to the git. I would like to check the content of the old XML from the current commit to the first commit. Is there any possibility to have all the files all the version which was added to the git including the deleted ones in the same folder with different name?

Mokus
  • 10,174
  • 18
  • 80
  • 122
  • Maybe this question might help: http://stackoverflow.com/q/278192/90874 – thSoft Sep 09 '13 at 15:02
  • Assuming you're asking this question to enable you to do further processing, you might find that asking about what you're trying to achieve in the end will result in a short-cut meaning you don't have to list out all of the revisions of all of the files. – Andrew Aylett Sep 09 '13 at 15:52

3 Answers3

1

You could alway just write a little bash script to do that for you.

dir=files;
filename=$1;

mkdir $dir;

for hash in $(git log --pretty=%H $filename); do
    git checkout $hash $filename;
    cp $1 $dir/$hash\_$filename;
done

This will put all versions of the file in a folder called files. You could make it more elaborate. Provide the folder name on the command line, check whether the folder exists and so on. Bit the main idea is there.

Honril Awmos
  • 192
  • 3
0

If you want to see all the changes in all the files between two commits, use git diff.

git diff longhashfirstcommit..longhashfromlatestcommit

You can get the commit hashes from running git log.

More here.

http://linux.die.net/man/1/git-diff
http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Viewing-Your-Staged-and-Unstaged-Changes

Nick Pyett
  • 3,338
  • 1
  • 23
  • 27
0

Assuming you're happy doing a little shell scripting, you should be able to combine git plumbing to get what you want.

git rev-list --all will list the hashes of all of the revisions in your repository.
git ls-tree -r <hash> will give you a listing of all of the files in a commit (or other tree-ish). You can split out the XML files by filtering this list, and extract their hashes.
git show <hash> will give you the content of a file, given its hash. You can redirect that content wherever you like.

To get you started, the following pipeline will give you a list of all of your XML files, with their hash and filename:

for i in `git rev-list --all` ; do git ls-tree -r $i ; done | grep ".xml$"
Andrew Aylett
  • 39,182
  • 5
  • 68
  • 95