3

我运行这个 git pull 命令,它阻塞了 Unicode 文件名

& git pull
From . 
  * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
    test-sample-files/MByte/CJK-UTF8-MultiByte/樣品套裝/サンプル.java
    test-sample-files/MByte/CJK-UTF8-MultiByte/樣品套裝/의 견본을 뽑다.java
    test-sample-files/MByte/japanese/これはサンプルのテストであり、できるだけ早く修正する必要があります.java
    test-sample-files/MByte/japanese/サンプル.java
    test-sample-files/MByte/korean/의 견본을 뽑다.java
Please move or remove them before you can switch branches.
Aborting
could not detach HEAD

但是 git status 报告工作目录干净

$ git status
# On branch dev/experimental
# Your branch and 'master' have diverged,
# and have 3 and 96 different commit(s) each, respectively.
#
nothing to commit (working directory clean)

没有“git add”、“git reset”或“rm ...*”可以解决这种情况。任何帮助深表感谢。

PS:我在 Mac OS X Leopard (10.5) 上运行“git version 1.7.5.4”,这是我能找到的最新的 leopard 预构建版本。

4

2 回答 2

3

在工作树的当前状态下,您的文件未跟踪。这就是为什么git addgit rm不做任何事情。

用 存储它们git stash save --untracked,它们将被保存在一个存储区中。拉取后,您可以恢复,git stash pop但您可能会遇到冲突,因为拉取将在可能的不同内容上签出主题。

由于您坚持使用 Git 1.7.5stash不知道该--untracked选项,因此您可以

  • 将未跟踪的文件移动到临时目录,并恢复它们:

     git ls-files --other --exclude-standard | xargs -t -I file  mv file untracked
    
  • 或添加它们git add -u,并提交

于 2012-04-17T22:23:56.270 回答
2

造成这种情况的原因已经在堆栈溢出中进行了描述,并且是使用 git 处理 Mac OS X UTF-8 编码文件名的解决方法!也有描述。

于 2012-04-18T16:29:42.877 回答