简体   繁体   中英

Using Git Bash on Windows, how do I checkout a branch that begins with a Unicode character?

I am using git bash.

I created a branch, did some changes and committed. When I tried to push, it gives me:

error "refpath does not exist".

I then checkout to other branch and retried to checkout to my branch but it says

error: pathspec 'tabViewComponent' did not match any file(s) known to git.

I did git branch , and it gives me branch name like this:

在此处输入图片说明

The branch name starts with the Unicode character 'START OF GUARDED AREA' (U+0096) that is difficult to distinguish from the ordinary dash character ( - ), only slightly wider on the font I am using.

Ways of entering Unicode characters at the command prompt differ by platform. You could copy it from the page linked above (or the command below) or use the compose sequence appropriate for your platform.

git checkout –tabViewComponent

On Windows, entering Unicode is done by default with

Unicode characters can then be entered by holding down Alt , pressing the + on the numeric keypad, followed by the hexadecimal code – using the numeric keypad for digits from 0 to 9 and letter keys for A to F digits – and then releasing Alt .

This is not a particularly friendly name for a branch because of all the trouble necessary to check it out and the confusion it will lead to if someone tries to use a leading dash. I strongly recommend renaming it to remove the leading U+0096.

I'd suggest you to checkout to that branch and rename it, before pushing it, to do so: with the numeric pad

git checkout ALT+96tabViewComponent
git branch -m ALT+96tabViewComponent:tabViewComponent

On ALT+96 don't forget the plus sign, if you got " ` " as the output, you forgot the plus sign (The Unicode character should be invisible )

Edit: ALT+96 means START OF GUARDED AREA and is a control character, you can also get the same character with Alt 0150

If you are a java person:

System.out.println("->\u0096<-");

And just copy the deadspace between the arrows of your output

Reference

Taking reference from https://www.htmlsymbols.xyz/unicode/U+0096 , I see the name of the branch contains at its start. can you try git checkout –tabViewComponent . Not sure if it a valid branch name.

解决问题的方法如下:

git remote update git fetch git checkout --track origin/<BRANCH-NAME>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM