简体   繁体   English

如何使用TortoiseGit提交区分大小写的重命名文件?

[英]How do I do commit a renamed file with case-sensitive using TortoiseGit?

I am trying a sample project to rename a file using Eclipse. 我正在尝试使用Eclipse重命名文件的示例项目。 First, I did a commit and pushed to GitHub. 首先,我做了一个提交并推送到GitHub。 The file was Samplemain.java . 该文件是Samplemain.java If I rename that file to SampleMain.java and if I try to commit the renamed file using TortoiseGit, I'm unable to commit. 如果我将该文件重命名为SampleMain.java并且尝试使用TortoiseGit提交重命名的文件,则无法提交。 Instead, it's showing an error with a small dialog. 而是显示一个带有小对话框的错误。

Please let me know the solutions for renaming files with case-sensitive in Git. 请让我知道在Git中使用区分大小写重命名文件的解决方案。 I am using Windows, the error dialog is shown below. 我正在使用Windows,错误对话框如下所示。 在此输入图像描述

This is a problem with TortoiseGit, not with Git itself. 这是TortoiseGit的问题,而不是Git本身。 If you commit using the command line it will work, I checked it now. 如果您使用命令行提交它将起作用,我现在检查它。 Note that renaming still takes 2 git mv commands, but only one git commit , as it should. 请注意,重命名仍然需要2个git mv命令,但只需要一个git commit

Another alternative is to rename the file on GitHub: when editing a file on GitHub notice at the top that you can change the name. 另一种选择是重命名GitHub上的文件:在GitHub上编辑文件时,请注意顶部可以更改名称。 After that you can pull from it. 之后,您可以从中退出。

Run following command in Windows command line (MINGW console). 在Windows命令行(MINGW控制台)中运行以下命令。 It should fix the case detection problem. 它应该修复案例检测问题。

git config core.ignorecase false

Two-stage rename... name it to something like 'z.tmp' then back to the name your really want. 两阶段重命名...将其命名为类似“ z.tmp”的名称,然后返回您真正想要的名称。

I know with Subversion I have to commit between two-step renames, but with Mercurial I don't. 我知道使用Subversion我必须在两步重命名之间进行,但是对于Mercurial我没有。

Not sure if Git needs it or not. 不知道Git是否需要它。

There's a utility made for this apparently: https://github.com/tawman/git-unite 有一个明显的实用工具: https//github.com/tawman/git-unite

I haven't been able to try it myself yet, as the author doesn't provide the final exe files, and I had an issue when trying to run the build script. 我还没有尝试过,因为作者没有提供最终的exe文件,我在尝试运行构建脚本时遇到了问题。 But it seems to be a utility that would solve this issue more easily. 但它似乎是一种可以更容易地解决这个问题的实用工具。

It searches for name-casing mismatches between repo and folders, and updates the repo to match the folder, letting you then commit with only one version of the files. 它搜索repo和文件夹之间的名称 - 外壳不匹配,并更新repo以匹配该文件夹,然后让您只提交一个版本的文件。 So just change the names in Windows explorer to what you want, then run the utility, I believe. 因此,我相信,只需将Windows资源管理器中的名称更改为所需名称,然后运行该实用程序即可。 (maybe followed by a commit -- not sure) (也许之后是提交-不确定)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM