From: guillaume weybrecht <guillaume.weybrecht@gmail.com>
To: git@vger.kernel.org
Subject: Case sensitivity when deleting a checked out branch
Date: Thu, 8 Mar 2018 20:57:54 +0100 [thread overview]
Message-ID: <420c2cd9-c38b-8f90-0fec-e070b19efb49@gmail.com> (raw)
Hello,
I came across an odd behavior in Git related to case sensitivity when
deleting a checked out branch.
I was not able to find much information about it.
$ git checkout -b foo
$ git branch -d foo # error: Cannot delete branch 'foo' checked
out => this is expected, nothing happens since you are on branch 'foo'
$ git branch -d Foo # Deleted branch Foo => this is not expected,
Git removed 'foo' from .git/refs/heads
Git removed the 'foo' file from .git/refs/heads, but did not update the
.git/HEAD file which still contains "ref: refs/heads/foo".
In fact, everything looks like a "git checkout --orphan foo":
$ git status # On branch foo. No commits yet (the working
tree is staged)
$ git log # fatal: your current branch 'foo' does not
have any commits yet
$ git rev-parse HEAD -- # fatal: bad revision 'HEAD'
$ git fsck # notice: HEAD points to an unborn branch (foo)
You can run "git checkout <other_branch>" to get back on your feet as
you would after "git checkout --orphan foo".
The thing is, you get there unexpectedly without any warning, just with
a case sensitivity mistake in "git branch -d".
Even it is seems unlikely to happen, someone ran into this at my job.
Tested on Windows 2.15.1.windows.2 and 2.16.2.windows.1, and on Mac OS
(I think it was a 2.14 version).
Best regards,
Guillaume
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
reply other threads:[~2018-03-08 19:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=420c2cd9-c38b-8f90-0fec-e070b19efb49@gmail.com \
--to=guillaume.weybrecht@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).