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

Re: 'git replace' and pushing

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 26, 2010, 21:43 UTC
Message-ID
<20101126214325.GC23462@burratino>
In-Reply-To
<AANLkTimQ3fjPb+YVJ5i8EAgui+gd5rfnXMvdQPJPeUtA@mail.gmail.com>
Hi Cory,
Cory Fields wrote:
> I realize that allowing replacements to be pushed "behind users backs", so
> I guess not respecting it makes sense.
>
> But is there no way that I can pull this off without rewriting hashes?

The usual way to accomplish what you are talking about would be like this:

 Real history
 ------------
 4' --- 5 --- 6
 1 --- 2 --- 3 --- 4
 Fake history
 ------------
 1 --- 2 --- 3 --- 4 --- 5 --- 6
 Replacement ref
 ---------------
 4' --> 4

This way, a person a person can fetch either piece of real history without trouble, and if they fetch the replacement ref, too, the history is pasted together.

It is not possible in git to push a commit without its ancestors; replacement refs do not change that. However, it is sort of possible to fetch a commit without its ancestors using the --depth option to clone and fetch.

Hope that helps, Jonathan

Previous: Cory FieldsNext: Junio C Hamano
Message 4 of 10 in “'git replace' and pushing”
  1. Cory FieldsNov 24, 2010
  2. Michael J GruberNov 25, 2010
  3. Cory FieldsNov 26, 2010
  4. Jonathan NiederNov 26, 2010
  5. Junio C HamanoNov 26, 2010
  6. Cory FieldsNov 27, 2010
  7. Martin von ZweigbergkNov 26, 2010
  8. Cory FieldsNov 27, 2010
  9. Jonathan NiederNov 27, 2010
  10. Cory FieldsNov 27, 2010

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.