% git archive --format tar master > archive.tar
% file archive.tar
archive.tar: POSIX tar archive

% tar cf a.tar archive.tar
% file a.tar
a.tar: POSIX tar archive (GNU)

7zip cannot unpack tar archive created by "git archive". Apparently there are some differences.

The reason I'm asking is that I would like to be able to unpack tar archive from git on Windows and 7zip is great utility. Is there some flag/workaround (short of unpacking tar archive created by git and packing it with GNU tar).

  • What error are you getting when you run 7zip and what is the command you are using for extraction? – vgoff Aug 9 '13 at 13:15

git-archive only creates PAX tar archives, and 7-Zip is incapable of reading PAX tar archives. Either use a different format with git-archive, post-process the archives created to recompress using tar, or use a different tool under Windows.

$: git archive --list

Do you get zip listed in the available archive list? Couldn't you simply use zip rather than tar to create them?

If you are using git for doing your archiving, you may wonder that there is not a way to extract the archive using the same tool. We are in luck, as there is, from the man pages:

       Extract commit ID from an archive created using git-archive.
  • Sure I can (actually I do now). Except I want to back up a relatively large number of files periodically (bitbucket.org/mrkafk/configbackup/wiki/Home) and so using bzip2 for compression would be preferable. – LetMeSOThat4U Aug 9 '13 at 13:55
  • They are already on bitbucket, and they are on your local repository. How many backups do you need? Really, just create another repository and maybe just package them with your 7zip after you fetch the repository? – vgoff Aug 9 '13 at 15:44
  • I do not want to backup bitbucket project! I want to back up my servers' config this way. – LetMeSOThat4U Aug 9 '13 at 15:58
  • Ah, you had given a bitbucket link as instructions rather than the object in question. Sorry, I had misunderstood the goal. I thought it was a git repository that could be easily pushed and pulled as a way to back up the files inherently. With bitbucket as the chosen host. Updating answer, to avoid 7zip using git tools. – vgoff Aug 10 '13 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.