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

Re: [BUG] Amending a shallow clone -> orphan branch

From
AMAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Date
Aug 6, 2021, 13:16 UTC
Message-ID
<20d768d5-2fe2-5540-b7e7-2174db7c80cf@syntevo.com>
In-Reply-To
<b3083a15-f2da-0eae-b07b-8a641c613906@gmail.com>
A bit more details:

$ git clone --depth 1 --single-branch --branch master https://github.com/git/git $ cd git

Here, a shallow clone is made with just 1 commit.
$ git show -s --pretty=%P HEAD

Outputs nothing; that's already a small bug. Surely the commit has parents!

$ git cat-file -p HEAD | grep parent
OK, that's better, finally the true parents are shown.

$ >1.txt $ git add 1.txt $ git commit --amend

Here, the top (and only in our clone) commit is amended.
$ git cat-file -p HEAD | grep parent
Nothing! This is the bug I'm reporting: amending the commit orphaned it.

To give a bit more background: I have a heavy-weight repo which I was testing on different machines. Since it's heavy, I decided to shallow clone just 1 commit. Upon testing on some machine, I found a small bug and amended a fix. Then I force-pushed. I expected the branch to be amended.

Instead, what I got was an orphaned branch, disconnected from all repo's branches, containing all files at once! Clearly not the best thing.

Previous: Alexandr MiloslavskiyNext: Alexandr Miloslavskiy
Message 4 of 5 in “[BUG] Amending a shallow clone -> orphan branch”
  1. Alexandr MiloslavskiyAug 6, 2021
  2. Bagas SanjayaAug 6, 2021
  3. Alexandr MiloslavskiyAug 6, 2021
  4. Alexandr MiloslavskiyAug 6, 2021
  5. Alexandr MiloslavskiyAug 6, 2021

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.