61

How can I unpack all objects of a pack file?

I've just cloned a remote repository, so my local repository currently doesn't contain any loose object, only a .pack and a .idx files.

I've tried running git unpack-objects < .git/objects/pack/pack-.pack, but nothing happens.

I'm doing something wrong? Is there any other command to do that?

3 Answers 3

79

You need to move the pack objects outside the .git/objects/pack directory before using the command. However, the pack files need to be inside the repository.

For example, create a directory name SAMPLE in your project's root. Then, move the pack files to SAMPLE directory. After that, inside the repository without the pack files, use the command

git unpack-objects < SAMPLE/*.pack

Git will generate all objects inside .git/objects directory of your repository.

Sign up to request clarification or add additional context in comments.

7 Comments

Hacky, but valid. The reason this works is that git unpack-objects won't create objects already in the repo, and seeing as the pack file is in the repo it does nothing. This is very clearly explained in get help unpack-objects.
thanks, just one thing - the pack files do not need to be inside the repo
When I try the command git unpack-objects -n < SAMPLE/*.pack, bash gives me an error: bash: SAMPLE/*.pack: ambiguous redirect. Is it because I'm trying to use the -n switch? I wanted to try a dry run before committing to the full unpack...
@WilsonF You have multiple or no pack files (probably multiple). You need to actually run the command once for every .pack file, and specify its actual filename (you can use tab-completion for that though)
This post (git unpack-objects < SAMPLE/*.pack) made me do a double-take and think I thought I was mistaken all these years about how Bash handles <. Bash cannot use the < operator with multiple files. You must iterate over them one at a time, e.g. for fn in SAMPLE/*.pack; do git unpack-objects < "$fn"; done.
|
1

move the *.pack file into .git folder , then go to .git directory and run the following command:

cat YOUR_PACK_FILE.pack | git unpack-objects

1 Comment

fatal: offset value out of bound for delta base object - from PowerShell
-5

Maybe you can try a simple command:

git clone ***.git

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.