Re: [BUG] Amending a shallow clone -> orphan branch
From: Alexandr Miloslavskiy <hidden>
Date: 2021-08-06 13:17:39
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.