From: Patakreyp Chandler <patakreyp.chandler@gmail.com>
To: git@vger.kernel.org
Subject: Git oddities with case of branch names on Windows
Date: Wed, 15 Feb 2023 14:28:38 +0100 [thread overview]
Message-ID: <CAAR1xzR9Vu8we4kBkd7rM2NAC63frxZs7Zr4wYNj3beNHtw0Mg@mail.gmail.com> (raw)
In-Reply-To: <CAAR1xzQwhbHNFFyTJQvkSVLJyJz_Gj5_FQ_udJrjM=ou+3GB3w@mail.gmail.com>
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@github.mycompany.com: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?
next parent reply other threads:[~2023-02-15 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAAR1xzQwhbHNFFyTJQvkSVLJyJz_Gj5_FQ_udJrjM=ou+3GB3w@mail.gmail.com>
2023-02-15 13:28 ` Patakreyp Chandler [this message]
2023-02-15 16:53 ` Git oddities with case of branch names on Windows Torsten Bögershausen
2023-02-16 7:03 ` Patakreyp Chandler
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAR1xzR9Vu8we4kBkd7rM2NAC63frxZs7Zr4wYNj3beNHtw0Mg@mail.gmail.com \
--to=patakreyp.chandler@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).