0

I did a git-unpack-objects on a .pack file. What I got was a lot of subdirectories from 00 to ff , each containing a lot of tiles with names as SHA1 hashes , but trying to display their contents gets me some junk. Now I need to get the actual source files from those hash files?

4
  • Do you need to do git unpack-objects? Why not just git cat-file?
    – Borealid
    Commented Feb 18, 2012 at 17:16
  • Why are you working directly with the .pack files? If you work with the full git repository, you can easily access the files with standard git commands ("git checkout", "git show", etc.). Packed files will be extracted by git without having to deal manually with pack files. Commented Feb 18, 2012 at 17:17
  • Due to bandwidth restrictions, I was not allowed to do a git-clone and git clone kept failing continuously. Hence I took the .pack and .idx files, zipped them as 700mb files, and now have got the .pack and .idx files. now I want to recreate my git source tree from those .pack and .idx files. Commented Feb 18, 2012 at 18:03
  • @Borelaid, all I have is only a .pack and .idx file. Initially I tried moving them to a different directory , unpacked them and I got a whiole lot of directories with files named after SHA1 hashes in them. I used git cat-file on one of those files and got a list. I was looking for a shortcut to create my source tree from those. I am lazy unfortunately :) Commented Feb 18, 2012 at 18:05

1 Answer 1

3

If you place the .pack files inside the .git/objects/pack/ directory of a newly git init'd repository, you should be able to git checkout -b somebranch ANYSHA1.

For example:

# find a commit:
faux@reg:~/git% git rev-parse HEAD
6f5e880c68099b185e60b2492c75e506e16d8292
faux@reg:~/git% cd ..

# init:
faux@reg:~% git init bar
Initialized empty Git repository in /home/faux/bar/.git/

# add packs:
faux@reg:~% cp git/.git/objects/pack/* bar/.git/objects/pack
faux@reg:~% cd bar

# checkout:
faux@reg:~/bar% git checkout -b somebranch 6f5e880c68099b185e60b2492c75e506e16d8292
Switched to a new branch 'somebranch'

# done!
faux@reg:~/bar% ls
abspath.c
contrib
...
3
  • Thank you very much for the detailed steps. I was struggling for the last one week. But now I am able to get the files. Will I be able to fetch/push/pull to the remote repository now? Do i need to make any changes in the .git directory to connect to the remote repository? How do I be able to switch to a branch that is available in the remote repository? Do I need to copy any files? Thank you very much again. Commented Feb 19, 2012 at 7:55
  • Actually I tried a git init and a git reset --hard, after git status reported me that the files were deleted. But your approach looks clean. Commented Feb 19, 2012 at 8:08
  • You should now be able to git remote add -f origin url://to/remote/repository, then git remote update will happily download very little (hopefully!), and you'll be able to continue as normal.
    – FauxFaux
    Commented Feb 19, 2012 at 13:28

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