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

Re: [PATCH] git-clone.txt: document that pushing from a shallow clone may work

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2009, 00:41 UTC
Message-ID
<7vr61c4x8q.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.0903041209070.8549@intel-tinevez-2-302>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
> On Wed, 4 Mar 2009, Junio C Hamano wrote:
>
>> Isn't the rule more or less like:
>> 
>>     If your shallow repository's history does not extend long enough and
>>     the other repository forked before your truncated history, wyou cannot
>>     compute the common ancestor and you cannot push out.
>
> Exactly.

Actually, come to think of it, it is a lot stronger than "cannot compute the common".

The history may look like this:
          R---R---R
         /
  --R---R---X---X---S---S---S

where S are the commits you have in your shallow repository, and R are the commits that exist in the repository that receives your push. Because your history is shallow, neither repository has 'X' that are the commits that need to exist in order to keep the history of recipient repository complete; the recipient is not shallow to begin with, and we do not want to make it shallow.

If you cloned shallowly some time ago, worked without communicating with the other side while the other side progressed, *AND* if the other side's progress included a rewind & rebuild of the history, you would see a similar topology. The leftmost 'S' in the above picture might have been the tip of the branch when you shallowly cloned with depth 1, and since then the remote end may have discarded topmost three commits and have rebuilt its history that leads to the rightmost 'R'. In such a case pushing to the remote's HEAD will fail.

Previous: Johannes SchindelinNext: Adeodato Simó
Message 10 of 11 in “pushing from a shallow repo allowed?”
  1. Joey HessFeb 12, 2009
  2. Mikael MagnussonFeb 16, 2009
  3. git-clone.txt: document that pushing from a shallow clone may workAdeodato Simó, Mar 3, 2009
  4. Johannes SixtMar 3, 2009
  5. Adeodato SimóMar 3, 2009
  6. Jay SoffianMar 3, 2009
  7. Adeodato SimóMar 4, 2009
  8. Junio C HamanoMar 4, 2009
  9. Johannes SchindelinMar 4, 2009
  10. Junio C HamanoMar 5, 2009
  11. Adeodato SimóMar 4, 2009

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.