简体   繁体   English

Git缺少远程上的分支名称

[英]Git missing branch name on remote

I have following situation, github is my origin, and I see there is branch with name Release1.0 . 我有以下情况,github是我的起源,我看到有一个名为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,分支名称中的大写字母可能有问题吗? Windows is case insensitive. Windows不区分大小写。

UPDATED to reflect an edge case that would mess with the checkout shortcut 更新以反映会checkout快捷方式的边缘情况


This means that you haven't yet created the local branch Release1.0 . 这意味着您尚未创建本地分支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. 分支存在于遥控器上,并且您拥有它的跟踪引用-这就是show origin输出告诉您的。

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. 这是checkout命令中内置的一种特殊情况“快捷方式”,因为通常要从一个可用的远程“复制”分支。 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. 如果有多个具有相同分支名称的远程服务器,则git将不知道要检出哪个远程服务器,因此将拒绝使用该快捷方式。

If you have a tag with the same name, git will check that out (in detached HEAD state) instead. 如果你有一个同名的标签, git会检查出来(处于分离的HEAD状态)。 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.) (在实践中, git对于任何给定命令的行为都有相当明智的规则,并且您始终可以在标记和分支之间进行歧义;但是最好不要考虑这些事情。)

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. 除快捷方式外,另一种方法是创建分支:可以使用-b选项(如错误消息所示),因为这是在checkout操作期间创建分支的更通用的方法。 Or you can use git branch . 或者您可以使用git branch

Unless there's more going on than you've spelled out, this is not a windows / case sensitivity issue. 除非发生的事情多于您所阐明的,否则这不是Windows /区分大小写的问题。 Note that saying "Windows is case insensitive" is not meaningful. 请注意,说“ Windows不区分大小写”是没有意义的。 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. Windows通常使用带有不区分大小写的文件名的文件系统是正确的,如果您尝试创建两个名称相同(大小写除外)的分支,这将导致问题。 But nothing says that branch names have to be all-lowercase (which would actually be a peculiar form of case-sensitivity). 但是并没有说分支名称必须全小写(实际上这是区分大小写的一种特殊形式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将git远程名称重命名为“上游” - Rename git remote name to “upstream” 如何重置整个Git存储库,而不只是重置“ Master”分支,以匹配Remote? - How to reset the entire Git repository, and not only the “Master” branch, to match Remote? 在远程计算机上运行批处理文件以更新git分支 - Run a batch file on a remote computer to update a git branch 捕获当前分支名称并在Windows上使用Git别名将其删除? - Capture current branch name and delete it using Git alias on Windows? 在 Windows 命令提示符下显示当前的 GIT 分支名称 - show current GIT branch name in windows command prompt 如果Windows上的分支名称无效,Git无法拉/取 - Git unable to pull/fetch if branch name is invalid on windows git远程添加 <name><url> 在Windows上似乎不起作用 - git remote add <name> <url> doesn't seem to work on windows 结帐git远程分支窗口时为什么会出现“无法创建目录”? - Why do I get “cannot create directory” when checkout a git remote branch windows? 批处理文件循环通过远程 Git 分支并将每个分支中的类似 CSV 文件复制到本地目录 - Batch File to Loop Through Remote Git Branches and Copy a Similar CSV File in Each Branch to a Local Directory 我们如何在 windows 的 git 目录上运行终端时显示分支名称? - How can we show branch name anytime we’re running terminal on git directory in windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM