由于未跟踪文件,Git 克隆失败,但所有分支都是干净的

标签 git

我正在尝试克隆 git 存储库。克隆失败并显示以下消息:

Untracked working tree file ... would be overwritten by merge.

我已经在所有分支上运行了git clean;没有一个有未跟踪的文件。
标记为未跟踪的文件仅在我当前工作的分支中使用并且被跟踪。

此外,当我 checkout 主分支,然后 checkout 我最初处理的分支时,我 checkout 成功,但打印了所谓未跟踪文件的名称。你知道这意味着什么吗?

Checking out files: 100% (477/477), done.

M       path-to-file-idenetified-as-untracked    
Switched to branch "Original_branch_name"

如何让克隆工作?

我读过有关克隆的内容。我正在制作克隆,因为我想与当前没有存储库的其他人共享它。

这是我输入的内容,稍作编辑。例如,我对 cd 执行了几个命令,这些命令没有显示出来。

$ git clone app.git clone/app.git
Initialized empty Git repository in /cygdrive/c/clone/app.git/.git/
error: Untracked working tree file 'C:/app.git/include/template/foo.xml' would be overwritten by merge.

$ git status
# On branch GT
nothing to commit (working directory clean)

$ git rm include/template/foo.xml
rm 'include/template/foo.xml'

$ git commit -m "Removed include/template/foo.xml because clone was failing with the message untracked working tree file would be overwritten by merge "
[GT]: created 77ca4ec: "Removed include/template/foo.xml because clone was failing with the message untracked working tree file would be overwritten by merge "
 1 files changed, 0 insertions(+), 89 deletions(-)
 delete mode 100755 include/template/foo.xml

$ git clone app.git clone/app.git
Initialized empty Git repository in /cygdrive/c/clone/app.git/.git/
Checking out files: 100% (522/522), done.

$ git commit -m "Added file deleted in previous commit after successfully cloning repository with file deleted"
[GT]: created f3eb7e8: "Added file deleted in previous commit after successfully cloning repository with
 file deleted"
 1 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 include/template/foo.xml

$ git clone app.git clone2/app.git
Initialized empty Git repository in /cygdrive/c/clone2/app.git/.git/
error: Untracked working tree file 'C://app.git/include/template/foo.xml' would be overwritten by merge.

最佳答案

您使用的 Git 版本是什么?在什么平台上?

根据操作系统的不同,您可能会遇到一些区分大小写的文件名问题,可能会导致此错误消息,如 this thread 中所示。

I renamed CONTRIB/ChangeLog to CONTRIB/ChangeLog.old and tried again and this time it complained about contrib/README.
Are the errors because of something I did? I

I believe this may be caused by the fact that I have renamed CONTRIB to contrib.
On a system which has no distinction between upper and lowercase names, maybe this leads to a conflict?

尝试删除整个 CONTRIB目录。如果失败,请尝试获取该存储库的新克隆。

这解决了它。谢谢。


But, once I added a copy of the file (which I need) and committed it, I tried to clone again and am back to the original failure message

这对我来说尖叫core.ignorecase设置为 true

core.ignorecase
If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like FAT.
For example, if a directory listing finds "makefile" when git expects "Makefile", git will assume it is really the same file, and continue to remember it as "Makefile".

The default is false, except git-clone(1) or git-init(1) will probe and set core.ignorecase true if appropriate when the repository is created.

你能检查一下是否git config -l包含 core.ignorecase设置?

关于由于未跟踪文件,Git 克隆失败,但所有分支都是干净的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2008190/

相关文章:

android - 如何在 Android 上使用 Git?

使用不同的 node_modules 文件夹进行 git checkout

git - 如何 git 只列出被跟踪的目录?

Git Merge 删除基础分支的新文件

android - 什么是 Repo,Google 为什么使用它?

使用 oauth token 进行身份验证的 Git/github 命令行应用程序?

ios - 无法打开文档 "Main.storyboard"

git - 在 Windows 批处理文件中捕获响应

php - 从本地主机移动到远程后,Wordpress 管理 URL 出现错误

git - 使用 no-ff merge IntelliJ 任务