Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore git repo from a pack file

Tags:

git

I am taking over some project, and I don't have a proper git repo but rather a pack-7dab97d983eeb36321c680bee7fde43688334f52.pack file. Can I restore a working git repository from it? And how?

like image 972
Dženan Avatar asked Dec 14 '22 17:12

Dženan


1 Answers

pack file contains only commits, so you don't have branch names, you have to guess them. A good starting points would be dangling commits.

  • create an empty repository
  • copy the pack to .git/objects/pack/
  • probably index the pack (I'm not sure if it needed or not)
  • run git fsck --lost-found
  • pick from found tips your probable branches

Note that it would fail if the pack file is only one of several from the original repository, as it may depend on objects which you don't have

like image 97
max630 Avatar answered Dec 17 '22 23:12

max630