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?
1 Answer
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
...
-
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
, thengit remote update
will happily download very little (hopefully!), and you'll be able to continue as normal.– FauxFauxCommented Feb 19, 2012 at 13:28
git unpack-objects
? Why not justgit cat-file
?