【问题标题】:Git untracked/unstaged files right after clone克隆后立即 Git 未跟踪/未暂存的文件
【发布时间】:2016-12-19 12:50:48
【问题描述】:

我克隆了一个 git 存储库,之后我在git status 中获得了未跟踪和未暂存(修改/删除)的文件。然后我为 Mac 设置了 fileMode=false,几个文件从 unstaged 中消失了。但我无法理解如何处理其他人。我从 stackoverflow 和其他地方尝试了很多东西,但没有任何帮助。

所以我的问题是为什么我在克隆 repo 后立即得到所有这些未跟踪/未暂存的文件,以及如何修复它。我使用 Mac 进行开发,但我尝试在 Windows 中克隆 repo 以查看它是否相同。更有趣的是:它说删除了一些未暂存的文件。

git config 不同修改后,git config -l 的命令如下:

苹果机:

filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
user.email=...hidden...
user.name=...hidden...
core.autocrlf=true
core.precomposeunicode=true
core.filemode=false
core.trustctime=false
alias.gr=log --graph --full-history --all --color --decorate
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
remote.origin.url=https://bitbucket.org/...hidden...
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.demo.remote=origin
branch.demo.merge=refs/heads/demo

获胜:

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=https://bitbucket.org/...hidden...
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.demo.remote=origin
branch.demo.merge=refs/heads/demo

我的git status 看起来像这样:

苹果机:

获胜:

如何解决?

【问题讨论】:

  • 所以你用两台电脑连接到一个仓库:Mac 和 Win?你的问题是为什么git status 在你从两台 PC 上以相同的方式克隆时两者都不一样?
  • 我的问题是为什么我在克隆 repo 后立即得到所有这些未跟踪/未暂存的文件,以及如何修复它。我使用 Mac 进行开发,但我尝试在 Windows 中克隆 repo 以查看它是否相同。更有趣的是:它说删除了一些未暂存的文件。
  • that 有帮助吗?您是否有任何理由不将问题限制在 Win OR Mac 上(我认为如果您解决一个问题,它们或多或少都会显示相同的问题,另一个也可能会解决)?建议:明确你尝试过的方法是尽量使问题尽可能简短。恕我直言,配置文件无济于事,但我可能错了。
  • 我看过这篇文章,有 2 个答案有帮助,一个是文件模式,另一个是小写双胞胎。但未跟踪的文件仍然存在。我不将问题限制在 Win 或 Mac 的原因是因为我不明白发生了什么,也许有 Windows 的人会回答这个问题,它也会在 Mac 上帮助我。另外,在这种情况下,我已经看到很多关于文件系统差异的帖子,所以我决定至少尝试其中的 2 个。但我还是不明白这个问题。文件名中有非拉丁 unicode(?) 字符,但是我应该怎么做才能让 git 正确理解呢?

标签: windows git macos git-clone git-untracked


【解决方案1】:

好的,经过一段时间的研究,我在this 帖子(Christoph 也提到)中找到了两个解决方案,即filemode=false 和小写双胞胎。但未跟踪的文件仍然存在。然后我了解到这些未跟踪的文件的文件名中包含 UTF8 字符,并且在某些地方这些字符被文件系统和/或 git 误解了。我查看了这些文件,发现它们不再是真实的,所以我只是删除了它们并提交了这次删除。

【讨论】:

  • 是的。我很高兴终于看到这条消息“没有什么可提交的,工作目录干净”:-)
猜你喜欢
  • 2014-11-10
  • 1970-01-01
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 2011-02-27
  • 1970-01-01
  • 2013-10-06
  • 1970-01-01
相关资源
最近更新 更多