简体   繁体   中英

Git missing branch name on remote

I have following situation, github is my origin, and I see there is branch with name Release1.0 . I see it also in my console:

xyz@yxz MINGW64 /c/myreponame (Development)
$ git remote show origin
* remote origin
Fetch URL: https://github.com/myorganization/myreponame
Push  URL: https://github.com/myorganization/myreponame
HEAD branch: Development
Remote branches:
Release1.0                          tracked
Development                         tracked

But when I try to switch to that branch I see:

xyz@yxz MINGW64 /c/myreponame (Development)
$ git checkout --track Release1.0 origin/Release1.0
fatal: Missing branch name; try -b

I think important note, here Im using Windows, may it is some problem with upper case in branch name? Windows is case insensitive.

UPDATED to reflect an edge case that would mess with the checkout shortcut


This means that you haven't yet created the local branch Release1.0 . The branch exists on the remote, and you have a tracking ref for it - that's what the show origin output is telling you.

But the checkout syntax you're using isn't correct for setting up the local branch to track the remote branch. Simply

git checkout Release1.0

will likely work. This is a special case "shortcut" built into the checkout command, because it's common to want to "copy" a branch from the one available remote. The cases where it won't work:

If there are multiple remotes with the same branch name, then git will not know which one to check out so will refuse to use the shortcut.

If you have a tag with the same name, git will check that out (in detached HEAD state) instead. In that case you can still create the branch (without the shortcut; see below), but beware of having a tag and a branch with the same name. (In practice git has fairly sensible rules for how any given command will behave, and you always can disambiguate between the tag and the branch; but it's better not to have to think about such things.)

The other way, besides the shortcut, to create the branch: you can use the -b option (as the error message indicates), as that's the more general way to create a branch during a checkout operation. Or you can use git branch .

Unless there's more going on than you've spelled out, this is not a windows / case sensitivity issue. Note that saying "Windows is case insensitive" is not meaningful. It is correct that Windows typically uses file system with case-insensitive filenames, and this would cause problems if you tried to create two branches whose names are identical except for case. But nothing says that branch names have to be all-lowercase (which would actually be a peculiar form of case-sensitivity).

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