Skip to content

Git for Win doesn't correctly handle branch names that differ only by case #1916

Closed
@robrich

Description

@robrich

Note: This feels like a problem with git fetch and/or git remote prune ... or with storing branches as folders. Feel free to 301 me to a better repository for this issue.

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?

64-bit Git version 2.19.1

$ git --version --build-options

git version 2.19.1.windows.1
cpu: x86_64
built from commit: 11a3092e18f2201acd53e45aaa006f1601b6c02a
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17134.345]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VisualStudioCode
Custom Editor Path:
Path Option: CmdTools
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: ConHost
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Enabled
Enable Builtin Rebase: Disabled
Enable Builtin Stash: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Happens on other environments, OS's, Windows versions, and git versions.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

// from machine 1
git clone https://some-url
git checkout -b BRANCH/UPPERCASE
git push origin BRANCH/UPPERCASE

// from machine 2
git clone https://some-url
git checkout -b branch/lowercase
git push origin branch/lowercase

// from machine 1
git fetch
// creates `origin/BRANCH/lowercase`
git remote prune origin
// removes `origin/BRANCH/lowercase`
git fetch
// creates `origin/BRANCH/lowercase`

// from machine 2
git fetch
// creates `origin/branch/UPPERCASE`
git remote prune origin
// removes `origin/branch/UPPERCASE`
git fetch
// creates `origin/branch/UPPERCASE`
  • What did you expect to occur after running these commands?

Git could keep branch/lowercase and BRANCH/UPPERCASE separate

  • What actually happened instead?

branch/lowercase became BRANCH/lowercase and BRANCH/UPPERCASE became branch/UPPERCASE because the branch folder already existed on machine 1, and the BRANCH folder already existed on machine 2, and Windows is a case-insensitive file system.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

I've reproed this concern with a private VSTS repo, but any Git hosting should do. I have no URL that demonstrates this issue.

Note: Git also can't have branch names with non-windows characters (<, >, :, ", /, \, |, ?, *) for the same reason, see also #1656 and https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions