0

I have an archived git repository in tar.gz format containing .pack file in object folder.

How can I extract source code from it?

7
  • git-archive is just a function to zip/tar a repository/commit - so what exactly is the problem? git-scm.com/docs/git-archive <- documentation. Commented Nov 12, 2016 at 4:02
  • One of my partners created a git archive and I see .pack in the tarball file. After doing some research, I found a way to unpack the .pack file but how can I get the source code of the project?
    – Ashit Vora
    Commented Nov 12, 2016 at 4:19
  • What happens when you simply unpack the .tar-file? What does it list? Just the .pack-file, or other files as well? Commented Nov 12, 2016 at 4:22
  • It has a buch of folders and one of them is "object" folder containing .idx and .pack file.
    – Ashit Vora
    Commented Nov 12, 2016 at 4:27
  • Then I'm assuming this is something like this: reviversoft.com/file-extensions/pack Commented Nov 12, 2016 at 4:29

1 Answer 1

1

Packfiles are one of the ways that git stores objects (see "Unpacking Git Packfiles"). From your comments, it looks like the archive contains the contents of the .git directory, in which case I'm guessing that the tarball also contains folders like info and refs in addition to objects.

So to get the actual source code, just untar the folder:

tar -xvf archive.tar.gz

and move the contents to a directory named .git. In other words, you should end up with a directory tree that looks like

myproject
|-- .git
|   |--objects
|   |  |-- pack
|   |  |   |-- pack-cdfae92.idx
|   |  |   |-- pack-cdfae92.pack

That will "create" the repository in your current directory. You can confirm this by running git status - it will say that you deleted a bunch of files. To repopulate the directory (ie, "undelete" the files), just run git checkout master.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .