threads / discuss / 29270

What's the best way to push/fetch replace refs?

Subject: What's the best way to push/fetch replace refs?

## tl;dr

3 messages between Dec 30, 2011 and Jan 2, 2012.

replies: 2people: 2as markdown or json

Slawomir Testowy· Dec 30, 2011, 11:59 UTC · lore

I want to use git-replace to connect two disjoined commits (git-svn didn't detect massive file movement) and I want to share these replace refs with others (we're moving from svn to git). I cannot use git-rebase because the history after the split contains lots of branches and merges and using git-rebase for that is an overkill.

I did something like this:

# Setup some repositories and create basic commit. git init --bare repo git init a git init b cd a echo a > a && git add a && git commit -m initial git branch tmp echo b > b && git add b && git commit -m second git checkout tmp echo c > c && git add c && git commit -m replacement

# Replace a commit with another one git replace `git rev-parse master` `git rev-parse tmp`

# Push changes to public repo; this doesn't push replace refs. git push --all ../repo/

# Is this the best way to push replace refs? git push ../repo/ 'refs/replace/*'

# Fetch commits from public repo cd ../b/ git pull ../repo/

# We didn't fetch replace refs in previous git-pull. But this seems to work. Is this the correct way? git fetch ../repo/ 'refs/replace/*:refs/replace/*'

# I also added "fetch = +refs/replace/*:refs/replace/*" to [remote "origin"] in "b" and this also seems to work.

Christian Couder· Dec 30, 2011, 14:51 UTC · re: Slawomir Testowy · lore

Re: What's the best way to push/fetch replace refs?

On Fri, Dec 30, 2011 at 12:59 PM, Slawomir Testowy <slawomir.testowy@gmail.com> wrote:

Show 7 quoted lines
>
> # I also added "fetch = +refs/replace/*:refs/replace/*" to [remote
> "origin"] in "b" and this also seems to work.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Yeah, the simplest is probably to just add "fetch = +refs/replace/*:refs/replace/*" to the remote(s) you want to get the replace refs from, and "push = +refs/replace/*:refs/replace/*" to the remote(s) you want to push the replace refs to.

Regards, Christian.

Slawomir Testowy· Jan 2, 2012, 06:16 UTC · re: Christian Couder · lore

Re: What's the best way to push/fetch replace refs?

2011/12/30 Christian Couder <christian.couder@gmail.com>:
Show 13 quoted lines
> On Fri, Dec 30, 2011 at 12:59 PM, Slawomir Testowy
> <slawomir.testowy@gmail.com> wrote:
>>
>> # I also added "fetch = +refs/replace/*:refs/replace/*" to [remote
>> "origin"] in "b" and this also seems to work.
>
> Yeah, the simplest is probably to just add "fetch =
> +refs/replace/*:refs/replace/*" to the remote(s) you want to get the
> replace refs from, and "push = +refs/replace/*:refs/replace/*" to the
> remote(s) you want to push the replace refs to.
>
> Regards,
> Christian.

Thanks Christian, I thought maybe there is some magic "git clone --get-also-replace-refs" or something. I'm asking because I'm about to tell people how to clone my repository and some of them don't know Git at all so I wanted to find out the simplest/best way to fetch replace refs.

Thanks.

← back to recent threads