无法签出连字符( - )开始的git分支 [英] Can't checkout git branch started with hyphen (-)

查看:737
本文介绍了无法签出连字符( - )开始的git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个git仓库。

这个仓库有一个类似于 -feature-abc 的远程分支。

当我输入 git checkout -feature-abc 时,我得到:

  error:unknown switch`e'

任何想法如何检出此分支?

解决方案

最后,我能够基于VonC的

解决方案1:
$ b

git checkout -b feature-abc origin / -feature-abc



解决方案2:



  • 进入您的工作副本的 .git / refs / remotes / origin

  • 找到名为 -feature-abc 的文件,
  • 获取分支的哈希值 cat 文件),
  • 然后检查出来,用一个理智的名字创建一个新的分支,

  • 使新分支跟踪远程分支。



  git checkout {hash} 
git checkout -b功能abc
git分支--set-upstream-to = origin / -feature-abc功能-abc

让现有的Git分支跟踪远程分支?


I have cloned a git repository.
This repository has a remote branch something like -feature-abc.
When I type git checkout -feature-abc, I get:

error: unknown switch `e'

Any idea how to checkout this branch?

解决方案

Finally I am able to get things working based on VonC's Answer.

Solution 1:

git checkout -b feature-abc origin/-feature-abc

Solution 2:

  • Go into your working copy's .git/refs/remotes/origin,
  • find the file named "-feature-abc",
  • get the hash of the branch (cat the file),
  • Then check it out, make a new branch with a sane name,
  • Make new branch track remote branch.

git checkout {hash}
git checkout -b feature-abc
git branch --set-upstream-to=origin/-feature-abc feature-abc

Make an existing Git branch track a remote branch?

这篇关于无法签出连字符( - )开始的git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆