git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
STSlawomir Testowy <slawomir.testowy@gmail.com>
Date
Dec 30, 2011, 11:59 UTC
Message-ID
<CAA61mJgCjt0O5LE5OQ=aNbtUHCZeZdZ=3dXYTNv_AhFi7JXwkA@mail.gmail.com>

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.

Next: Christian Couder
Message 1 of 3 in “What's the best way to push/fetch replace refs?”
  1. Slawomir TestowyDec 30, 2011
  2. Christian CouderDec 30, 2011
  3. Slawomir TestowyJan 2, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.