文件名大小写更改时如何切换分支? [英] How to switch branch when filename case changes?

查看:150
本文介绍了文件名大小写更改时如何切换分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我有一个分支development和一个文件Config.json.
  2. 我正在创建一个新的分支new_development,在其中将Config.json重命名为config.json并提交.
  3. 我切换回development来查看该分支中的某些内容.没有错误.
  4. 我切换到new_development以继续处理新内容.它显示了一个错误:
  1. I have a branch development with a file Config.json.
  2. I am creating a new branch new_development, where I rename Config.json to config.json and commit.
  3. I switch back to development to see how some things were made in that branch. No errors.
  4. I switch to new_development to continue work on new stuff. It shows an error:

错误:结帐将覆盖以下未跟踪的工作树文件:

error: The following untracked working tree files would be overwritten by checkout:

   Config.json

在切换分支之前,请先移动或移除它们.

Please move or remove them before you switch branches.

正在中止

文件实际上在git中.

The file is actually in git.

我有这个git配置:

[core]
    ignorecase = false

当相同文件的大小写不同时,如何使分支切换工作?

How do I make branches switching work when the same files have different case?

推荐答案

当相同文件的大小写不同时,如何使分支切换工作?

How do I make branches switching work when the same files have different case?

core.ignoreCase更改回true.

您使用的是不区分大小写的文件系统; git使用core.ignoreCase设置来表明这一点.它是在创建存储库时配置的(通过git initgit clone):git查看文件系统以确定是否区分大小写,并缓存该信息(在core.ignoreCase设置中),以便不必为每个操作都执行此查找.

You are on a case insensitive filesystem; git uses the core.ignoreCase setting to indicate that. It is configured when you create a repository (either via git init or by git clone): git looks at your filesystem to determine whether it's case sensitive or not, and caches that information (in the core.ignoreCase setting) so that it doesn't have to do this lookup for every operation.

这不是您要更改的设置.

This is not a setting that is meant for you to change.

对于不敏感文件系统,使用core.ignoreCase = false:

% git ls-tree HEAD
100644 blob 257cc5642cb1a054f08cc83f2d943e56fd3ebe99    foo
% git ls-tree branch
100644 blob bcc9cdfd113753edf279e92afd622b0f3bb05fbc    FOO
% git checkout branch
error: The following untracked working tree files would be overwritten by checkout:
    FOO
Please move or remove them before you switch branches.
Aborting

这是因为我告诉git我的文件系统 区分大小写.它查看了我要检出的树,发现当前的HEAD树中有一个名为FOO的文件,该文件为 not ,然后在磁盘上查看是否有具有相同名称的未跟踪工作文件.它stats文件FOO(实际上是文件foo,因为我们使用的是不区分大小写的文件系统),并意识到您在工作目录中有未跟踪的文件.

This is because I've told git that my filesystem is case sensitive. It looks at the tree that I'm trying to check out, sees that there's a file called FOO that is not in my current HEAD tree, and then looks on disk to see if there's an untracked working file with the same name. It stats the file FOO (which is really the file foo, since we're on a case insensitive filesystem) and realizes that you have an untracked file in the working directory.

当然,除了,您没有.您有文件foo.

Except, of course, you don't. You have the file foo.

如果我对此进行了纠正,将core.ignoreCase设置为反映文件系统的实际情况,则可以正确切换分支:

If I correct this, setting core.ignoreCase to reflect the reality of my filesystem, then I can switch branches properly:

% git config core.ignoreCase true
% git checkout branch
Switched to branch 'branch'
% git ls-tree HEAD
100644 blob bcc9cdfd113753edf279e92afd622b0f3bb05fbc    FOO

这篇关于文件名大小写更改时如何切换分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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