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?
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?
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.
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 )