首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法获取干净的GIT工作区。未跟踪文件,删除后将其删除

无法获取干净的GIT工作区。未跟踪文件,删除后将其删除
EN

Stack Overflow用户
提问于 2016-05-10 17:25:23
回答 1查看 259关注 0票数 0

当我试图更新(拉入)我的本地git存储库的更改时,我得到的错误是有未跟踪的文件:

代码语言:javascript
复制
> 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来确认这一点

代码语言:javascript
复制
> 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来创建一个干净的工作目录:

代码语言:javascript
复制
> 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,它显示该文件已被删除(但这意味着它以前被跟踪过?):

代码语言:javascript
复制
> 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"

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

EN

回答 1

Stack Overflow用户

发布于 2016-05-10 17:40:44

好像是ü出了点问题。

也许可以尝试执行git checkout .,这将恢复您对跟踪的文件所做的所有更改,从而恢复它认为存在的删除。

我希望它不会再次显示为未跟踪。会很奇怪。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37134334

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档