15

I'm wondering how to pull a repo with all of the commits that have not been gc'd, if that is possible..

is it something like:

$ git clone x
$ cd x
$ git fetch origin -f

? or something else?

2
  • What are you trying to accomplish? Maybe if we know why you need this, we can give you a better answer. Normally the owner of the remote repository will reference commits that they want to be fetchable. Dangling commits that haven't been gc'd are at risk to be lost at any time. Commented Sep 13, 2011 at 14:32

2 Answers 2

5
+50

There is no command I'm aware of which says "bring down all commit objects in the remote repository, even those that are unreferenced".

You can only bring commits with a reference in the remote repository. You can do this with the command:

git fetch [remote] [remoteBranch]:[localBranch]

The remote repository will need to create a reference to any dangling commits before you can fetch them. If you have access to the remote repository, you can do this with a command like:

git fsck --lost-found

The output will show you any dangling commits. Give them a reference with git branch [branchname] [commit sha1], then you can fetch them.

1

I don't know whether there is a way to pull all unlinked commits, but if you know the hash of a specific unlinked commit that you are interested in, then you can fetch it using git fetch origin <commitHash>:refs/remotes/origin/orphaned-commit (originally from here: https://stackoverflow.com/questions/25416003/clone-a-git-repository-and-keep-unreachable-commits#comment53417187_25416117 )

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Toto
    Commented Jun 17 at 16:53
  • @Toto Edited according to your suggestion.
    – P. Cahyna
    Commented Jun 18 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .