git-pack-refs - Linux


git-pack-refs is a Git command used to prepare local repository references for efficient network transfer. It builds a packfile containing the entire ref namespace, which serves as a snapshot of the references at a specific point in time.


git pack-refs [--all] [--prune] [--stat] [--local]


  • –all: Pack all refs, including those for tags and remotes.
  • –prune: Remove dangling refs from the packfile.
  • –stat: Show statistics about the created packfile.
  • –local: Pack only local refs, excluding tags and remotes.


  • Pack all refs:

    git pack-refs --all
  • Pack only local refs:

    git pack-refs --local
  • Pack and prune dangling refs:

    git pack-refs --all --prune
  • Show statistics on the created packfile:

    git pack-refs --stat

Common Issues

  • Error: No refs to pack: This occurs when there are no references in the repository. Ensure there are objects and commits in the repository before packing refs.


git-pack-refs can be used with git push to efficiently transfer the ref namespace to a remote repository.

git push --all --tags remote-name refs/heads

Related Commands

  • git fetch: Downloads references from a remote repository.
  • git push: Uploads references to a remote repository.