【问题标题】:Unable to get clean GIT workspace. File is untracked, after deletion it is deleted [duplicate]无法获得干净的 GIT 工作区。文件未跟踪,删除后删除[重复]
【发布时间】:2016-05-10 09:25:22
【问题描述】:

当尝试更新(拉取)对我的本地 git 存储库的更改时,我收到错误消息:存在未跟踪的文件:

> git pull origin
Updating 556678a..e6eb9b0
error: The following untracked working tree files would be overwritten by merge:
        templates/Sammel RKA Süddeutsche EM MU15 am 17.10.2015.doc
Please move or remove them before you can merge.
Aborting

我可以使用git status 确认这一点:

> git status
On branch feature/KRAS-6
Your branch is behind 'origin/feature/KRAS-6' by 16 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        "templates/Sammel RKA Su\314\210ddeutsche EM MU15 am 17.10.2015.doc"

nothing added to commit but untracked files present (use "git add" to track)

然后我使用git clean 拥有一个干净的工作目录:

> git clean -f -n
Would remove "templates/Sammel RKA Su\314\210ddeutsche EM MU15 am 17.10.2015.doc"
> git clean -f   
Removing "templates/Sammel RKA Su\314\210ddeutsche EM MU15 am 17.10.2015.doc"

现在查看git status,显示该文件已被删除(但这意味着它之前被跟踪过?):

> git status
On branch feature/KRAS-6
Your branch is behind 'origin/feature/KRAS-6' by 16 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    "templates/Sammel RKA S\303\274ddeutsche EM MU15 am 17.10.2015.doc"

no changes added to commit (use "git add" and/or "git commit -a"

知道如何清理这个烂摊子吗?是否与文件名中的空格或特殊字符有关?

【问题讨论】:

    标签: git


    【解决方案1】:

    ü 似乎有问题。
    也许尝试做git checkout . 这应该会恢复您对跟踪文件所做的所有更改,从而恢复它认为存在的删除。
    我希望它不会再次显示为未跟踪。会很奇怪。

    【讨论】:

    • 按照你的建议做了。它再次显示为未跟踪:未跟踪文件:“templates/Sammel RKA Su\314\210ddeutsche EM MU15 am 17.10.2015.doc”`
    • 嗯,问题是ü。在 Unicode 中,您可以直接使用 ü 字符,或者使用 u 后跟一个组合分音符号(上面的点)。它以第一种形式存储在 Git 中,但不知何故,如果您在本地拥有该文件,它会以第二种形式被识别。这意味着如果文件在那里,它会将其视为不同的文件,如果不存在,则将其视为丢失的文件。很奇怪的情况。如果您 git add 未跟踪的文件会怎样?
    • 嗯,奇怪。添加后,识别为新文件。
    • 好的,试试下面的。执行git reset,然后应该再次取消跟踪。然后将文件重命名为不带ü 的名称。然后尝试将其重命名为旧名称,但不要使用复制和粘贴,而是真正输入ü。然后查看git status 的内容。
    • 真的很有趣...在git reset 之后,它确实又是untracket 了。重命名操作后,它仍然未被跟踪(Su\314\210ddeutsche),但另外显示了一个未暂存以提交的更改(相同的文件,但“S\303\274ddeutsche”)。
    猜你喜欢
    • 2016-02-27
    • 2018-07-21
    • 2017-05-10
    • 2011-11-27
    • 2017-10-23
    • 2014-02-12
    • 1970-01-01
    • 1970-01-01
    • 2013-11-17
    相关资源
    最近更新 更多