bug: git branch -d and case-insensitive file-systems
- From
- Aaron Dufour <thedufer@gmail.com>
- Date
- Aug 24, 2015, 16:11 UTC
- Message-ID
- <CAJrRhQz1UmnDi6Giejetfoh3aPX08aYcgY-neZfcKjpUav0=sA@mail.gmail.com>
I use git (2.2.1) on OS X (10.9.5) and recently my repo got into a bad state. I think this involves a mis-handling of case-insensitive file systems.
This reproduces the problem:
> git init
Initialized empty Git repository in /Users/aarond_local/code/git-test/.git/
> git commit --allow-empty -m 'first commit'
[master (root-commit) 923d8b8] first commit
> git checkout -b feature
Switched to a new branch 'feature'
> git checkout -b Feature
fatal: A branch named 'Feature' already exists.
> git checkout -B Feature
Switched to and reset branch 'Feature'
> git branch -d feature
Deleted branch feature (was 923d8b8).
> git log
fatal: bad default revision 'HEAD'This is the behavior when there isn't a case mismatch, which is what I would have expected in the previous case as well:
> git init
Initialized empty Git repository in /Users/aarond_local/code/git-test/.git/
> git commit --allow-empty -m 'first commit'
[master (root-commit) 48df19f] first commit
> git checkout -b feature
Switched to a new branch 'feature'
> git branch -d feature
error: Cannot delete the branch 'feature' which you are currently on.I can also reproduce the issue on git 2.5.0.
-Aaron Dufour