Git oddities with case of branch names on Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Here is a scenario for some oddities (bugs?) for case of branch names
(at least with git version 2.37.3.windows.1).

First, we have created an empty git repository on our internal GitHub
server and we clone this repository
    $ git clone git@xxxxxxxxxxxxxxxxxxxx:ID123456/test_branches.git ppppppp
    Cloning into 'ppppppp'...
    warning: You appear to have cloned an empty repository.

Then we create an object in this repository on main branch, we add,
commit and push it:
    $ cd ppppppp/
    $ echo foo > foo
    $ git add foo
     warning: in the working copy of 'foo', LF will be replaced by
CRLF the next time Git touches it
    $ git commit -m 'foo'
     [main (root-commit) 51789b0] foo
     1 file changed, 1 insertion(+)
     create mode 100644 foo
    $ git push
     Enumerating objects: 3, done.
     Counting objects: 100% (3/3), done.
     Writing objects: 100% (3/3), 869 bytes | 869.00 KiB/s, done.
     Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
     To github.mycompany.com:ID123456/test_branches.git
     * [new branch]      main -> main

We create a new branch in this repository and switch to it:
    $ git checkout -b gggg
     Switched to a new branch 'gggg'

We create an object in this repository on the new branch, we add,
commit and push it:
    $ echo bar > bar
    $ git add bar
     warning: in the working copy of 'bar', LF will be replaced by
CRLF the next time Git touches it
    $ git commit -m 'bar'
     [gggg 8f2fdd0] bar
     1 file changed, 1 insertion(+)
     create mode 100644 bar
    $ git push --set-upstream origin gggg
     Enumerating objects: 4, done.
     Counting objects: 100% (4/4), done.
     Delta compression using up to 4 threads
     Compressing objects: 100% (2/2), done.
     Writing objects: 100% (3/3), 929 bytes | 929.00 KiB/s, done.
     Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
     remote:
     remote: Create a pull request for 'gggg' on GitHub by visiting:
     remote:
https://github.mycompany.com/ID123456/test_branches/pull/new/gggg
     remote:
     To github.mycompany.com:ID123456/test_branches.git
     * [new branch]      gggg -> gggg
     branch 'gggg' set up to track 'origin/gggg'.

If we look at the local branches, everything is normal:
    $ git branch -vv
     * gggg 8f2fdd0 [origin/gggg] bar
       main 51789b0 [origin/main] foo

Now we “switch” to the exact same branch but with a typo (here, 'GGGG'
instead of 'gggg') in the case of branch name (this does not work with
git on Linux "error: pathspec 'GGGG' did not match any file(s) known
to git."):
    $ git checkout GGGG
     Switched to branch 'GGGG'

We create an object in this repository on the (not really) new branch
(with faulty case name), we add, commit and (try to) push it:
    $ echo foobar > foobar
    $ git add foobar
     warning: in the working copy of 'foobar', LF will be replaced by
CRLF the next time Git touches it
    $ git commit -m 'foobar'
     [GGGG 2ed967b] foobar
     1 file changed, 1 insertion(+)
     create mode 100644 foobar
    $ git push
    fatal: The current branch GGGG has no upstream branch.
    To push the current branch and set the remote as upstream, use
            git push --set-upstream origin GGGG
    To have this happen automatically for branches without a tracking
    upstream, see 'push.autoSetupRemote' in 'git help config'.

Pushing actually fails because git says "The current branch GGGG has
no upstream branch ", and if we check this badly cased branch ("GGGG")
has no upstream tracked branch, but is still the same correctly cased
branch ("gggg"):
    $ git branch -vv
     * GGGG 2ed967b foobar
        main 51789b0 [origin/main] foo
    $ git branch -a
     * GGGG
       main
       remotes/origin/gggg
       remotes/origin/main

Switching back to the correctly cased branch does not seem to put back
everything in order (list of branches is broken), but "git push"
works, at least:
    $ git checkout -
     Switched to branch 'gggg'
       Your branch is ahead of 'origin/gggg' by 1 commit.
       (use "git push" to publish your local commits)
    $ git branch -vv
     GGGG 2ed967b foobar
     main 51789b0 [origin/main] foo
    $ git push
     Enumerating objects: 4, done.
     Counting objects: 100% (4/4), done.
     Delta compression using up to 4 threads
     Compressing objects: 100% (2/2), done.
     Writing objects: 100% (3/3), 962 bytes | 962.00 KiB/s, done.
     Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
     To github.mycompany.com:ID123456/test_branches.git
     8f2fdd0..2ed967b  gggg -> gggg

Even trying to switch to other branches, still does not correct this situation:
    $ git branch -vv
      GGGG 2ed967b foobar
      main 51789b0 [origin/main] foo
    $ git checkout main
     Switched to branch 'main'
     Your branch is up to date with 'origin/main'.
    $ git branch -vv
       GGGG 2ed967b foobar
     * main 51789b0 [origin/main] foo
    $ git checkout gggg
     Switched to branch 'gggg'
     Your branch is up to date with 'origin/gggg'.
    $ git branch -vv
      GGGG 2ed967b foobar
      main 51789b0 [origin/main] foo
   $ git branch -a
      GGGG
      main
     remotes/origin/gggg
     remotes/origin/main
    $ git checkout Gggg
     Switched to branch 'Gggg'
    $ git branch -a
      GGGG
      main
      remotes/origin/gggg
      remotes/origin/main

 Any idea of what's going on? And how to fix it?




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux