Thread (5 messages) flat view 5 messages, 2 authors, 2021-08-06

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

From: Bagas Sanjaya <hidden>
Date: 2021-08-06 12:21:30

Hi Alexandr, welcome to Git mailing list!

On 06/08/21 07.04, Alexandr Miloslavskiy wrote:
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):
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help