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

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

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Aug 6, 2021, 12:21 UTC
Message-ID
<b3083a15-f2da-0eae-b07b-8a641c613906@gmail.com>
In-Reply-To
<64760969-1ead-2bfb-6f98-1161d385c0ca@syntevo.com>
Hi Alexandr, welcome to Git mailing list!
On 06/08/21 07.04, Alexandr Miloslavskiy wrote:
Show 14 quoted lines
> Consider the following steps :
> 
> git clone --depth 1 --single-branch --branch master 
> https://github.com/git/git
> cd git
>  >1.txt
> git add 1.txt
> git commit --amend
> 
> This results in an orphaned branch, where a single commit contains 
> entire tree.
> 
> I understand that this is a bug, because certainly git knew shallow 
> commit's parents and could reuse that when amending?
I tested that, and below is `git status` after the test (using Git 2.32.0):
Show 6 quoted lines
> On branch master
> Your branch and 'origin/master' have diverged,
> and have 1 and 1 different commits each, respectively.
>   (use "git pull" to merge the remote branch into yours)
> 
> nothing to commit, working tree clean

So you're amending merge commit by adding dummy file, so that your `master` branch becomes divergent against origin. That dummy file isn't contained in any commits that are included with that merge commit.

-- 
An old man doll... just what I always wanted! - Clara
Previous: Alexandr MiloslavskiyNext: Alexandr Miloslavskiy
Message 2 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.