Graphs exist within the hierarchy of refs/replace/
. (Or maybe it’s better to say that such links "owe their existence".) To transfer them from one store to another, you must click or get such links.
For instance:
git push origin refs/replace/5c714d7798d1dc9c18d194fa6448680515c0ccdb
when commit 5c714d7798d1dc9c18d194fa6448680515c0ccdb
has a replacement (in my case the replacement was a new commit object ceba978ce6dad3b52d12134f4ef2720c5f3a9002
, i.e. Git usually does not see " 5c714d7
, instead of the replacement object ceba978
).
To complete all replacements:
git push origin 'refs/replace/*:refs/replace/*'
(quotes are sometimes needed so that the shell does not distort the stars, exactly when and what quotes to use depends on the shell, although single and double quotes work on all Unix-y shells).
Selection Notes for Download
If some remote R has replacements, and you want to bring them all to your repository, use git fetch R 'refs/replace/*:refs/replace/*'
(or the same with the +
prefix, if you want, so that their replacements redefine everything that you already have). You can automate this for any repository and remote. For example, if you run git config --edit
, you will find that the existing origin
remote has several options that look like this:
[remote "origin"] url = ... fetch = +refs/heads/*:refs/remotes/origin/*
Just add the line:
fetch = refs/replace/*:refs/replace/*
or
fetch = +refs/replace/*:refs/replace/*
so that your Git delivers them to Git refs/replace/*
. (Note: there are no quotes here, because the shell is not going to process this line.) The leading plus sign has the same meaning as usual: 1 without it, if you already have a link, you hold on and ignore them. With the leading plus sign, you drop yours and use them instead. As with tags, if your link and their link already match, it doesn’t matter whether you keep yours or replace yours; it matters only when you have different ideas about which object some link should point to.
1 In fact, the “usual value” for the leading plus sign depends on whether the link should move, such branch names or should not move, such as the tag name. The plus sign sets the force flag, i.e. “Always accept the proposed new settings,” but for branch names that are expected to “move forward”, updating is allowed without force if and only if it is “forward” (or “fast forward”). Git initially applied this rule to other links, such as tags, but Git people fixed it in Git 1.8.2. It’s not clear to me what Git rules apply to refs/replace/
links that should not be moved, but are not handled additionally specifically, like tags.