GitHub分支机构:区分大小写的问题? [英] GitHub Branches: Case-Sensitivity Issue?

查看:159
本文介绍了GitHub分支机构:区分大小写的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于远程上有一些分支,我似乎对存储库不断在本地重新创建分支有问题。我在Windows计算机上,因此我怀疑这是区分大小写的问题。

I seem to be having an issue with a repository continually recreating branches locally because of some branches on remote. I'm on a Windows machine, so I suspect that it's a case sensitivity issue.

以下是几个示例命令:

$ git pull
From https://github.com/{my-repo}
 * [new branch]          Abc -> origin/Abc
 * [new branch]          Def -> origin/Def
Already up to date.

$ git pull -p
From https://github.com/{my-repo}
 - [deleted]             (none)     -> origin/abc
 - [deleted]             (none)     -> origin/def
 * [new branch]          Abc -> origin/Abc
 * [new branch]          Def -> origin/Def
Already up to date.

在执行 git pull 时,分支有问题的大写。当我执行 git pull -p (用于修剪)时,它首先尝试删除分支的小写版本,然后创建大写版本。

When doing a git pull, the branches in question are capitalized. When I do a git pull -p (for pruning), it first tries to delete lowercased versions of the branches, then create capitalized versions.

远程分支机构使用大写(来源/ Abc 来源/Def)。

The remote branches are capitalized (origin/Abc and origin/Def).

我试图临时更改我的Git配置,以使 ignorecase = false (当前为 ignorecase = true )。但是我注意到行为没有变化。我猜我的本地端当前正在保留这些小写的分支。但是 git分支不会在本地显示这些分支的任何版本。

I have tried to temporarily change my Git config such that ignorecase=false (it is currently ignorecase=true). But I noticed no change in behavior. I'm guessing there's something local on my end that's currently holding onto those lowercased branches. But git branch does not show any version of these branches locally.

完全删除存储库的时间(新鲜在单独的文件夹中的 git clone 在尝试拉取/提取操作时不会拉出这些幻影分支),我能做些什么吗?

Short of completely obliterating the repository (a fresh git clone in a separate folder does not pull these phantom branches when trying pulls/fetches), is there anything I can do?

推荐答案

在Git上,分支只是指向提交的指针。分支以纯文件格式存储在 .git 存储库中。

On Git, branches are just pointers to a commit. The branches are stores as plain files on your .git repository.

例如,您可能有 abc def 个文件在 .git / refs / heads 上。

For instance you may have abc and def files on .git/refs/heads.

$ tree .git/refs/heads/
.git/refs/heads/
├── abc
├── def
└── master

这些文件只是分支指向的提交编号。

The content of these files is just the commit number on which the branch is pointing.

我不确定,但是我认为 ignorecase 选项仅与您的工作目录相关,与 .git 文件夹。因此,要删除奇怪的大写分支,您可能只需要删除/重命名 .git / refs / heads 中的文件。

I am not sure, but I think the option ignorecase is only relevant to your working directory, not the .git folder. So to remove the weird capitalized branches, you may just need to remove/rename the files in .git/refs/heads.

除此之外,从本地分支到远程分支的上游链接存储在 .git / config 文件。在此文件中,您可能会喜欢:

In addition to this, the upstream link from a local branch to a remote branch is stored on the .git/config file. In this file you may have something like:

[branch "Abc"]
        remote = origin
        merge = refs/heads/abc

在此示例中,注意将远程分支命名为 Abc ,但本地分支为 abc (小写)。

Notice in this example that the remote branch is named Abc but the local branch is abc (lowercase).

要解决您的问题,我将尝试:

To solve your issue I would try to:


  1. 修改 .git / config 文件

  2. .git / refs / heads 如 abc 重命名为 abc旧

  3. 尝试您的 git pull

  1. Modify the .git/config file
  2. Rename the corrupted branches in .git/refs/heads such as abc is renamed abc-old
  3. Try your git pull

这篇关于GitHub分支机构:区分大小写的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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