2013-04-11 122 views
12

我已经通过关注this tutorial将SVN存储库转换为Git。现在似乎无法提取像this answer中建议的子存储库。Git不会恢复或提交它认为被修改的文件

原谅长文章,但大部分文本是格式良好的git输出。

操作系统:Windows 8 命令行:MinGW的 Git版本:1.8.1.msysgit.1

中提取subrepository似乎并没有工作,除非你有一个干净的临时区域和没有修改的过程文件。

git status告诉我,我有一个修改过的文件,即使这是一个新鲜的SVN导入。好的,让我们试着摆脱它。

尝试并恢复文件。

user$ git status 
# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: folder with space/folder/toolbar.png 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

user$ git checkout -- "folder with space/folder/toolbar.png" 

user$ git status 
# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: folder with space/folder/toolbar.png 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

这并没有奏效,但我并不在乎是否提交,所以我会尝试下一步。

user$ git commit -a -m "Testing if committing fixes it" 
# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: folder with space/folder/toolbar.png 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

user$ git status 
# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: folder with space/folder/toolbar.png 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

通过跳过暂存提交不起作用,所以让我们先尝试着手。

user$ git add "folder with space/folder/toolbar.png" 

user$ git status 
# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: folder with space/folder/toolbar.png 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

无法正常工作,所以我很难过...去问一个更聪明的人。

我是git的新手,但很熟悉汞,并且已经阅读this online tutorial以启动自己。

我完全有可能搞砸了一个简单的命令。

已经尝试过: 我环顾四周,解决我的具体问题,但有一点运气。我偶然发现了this answer这似乎相关,但不能解决我的问题。

编辑:可能有趣的事 这是让我困惑的部分。前段时间我推出了这个回购协议进入在线资源库。新鲜的克隆后,回购仍然认为文件被修改(即git status返回相同的结果,我已经设置git config --global core.autocrlf false并验证通过运行git config --global core.autocrlf确实返回false)。

编辑2:解决发现的,但问题仍然没有完全理解 我已经成功通过简单地从系统中,临时区域删除文件,然后提交更改修复库。 之后,我将文件复制回来并将其提交到存储库。

问题虽然固定,但只会让我更困惑。

当我玩弄移除文件时,我注意到如果我重置版本库到最后一次提交已删除文件的HEAD,git status将表示没有任何更改,并且该文件未被跟踪,但是文件将被恢复在我的工作树。这是奇怪的,因为它被标记为在git中被删除...

只有在第二次删除它后,即使git不再记住它,我是否设法实际删除它,以便git resetgit reset --hard不会恢复该文件。

如果有人能请解释我是如何陷入这种状态下,如果是在Git中或正常行为的错误我将不胜感激。

我suspitions 我已经失去了我使用,但发生了什么事去像这样的命令序列: 该文件是Images/toolbar.png,我已经航行到Images文件夹。

之后我删除它从文件系统Git的检测,像这样的变化:

# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  deleted: toolbar.png 
#  deleted: ../images/toolbar.png 
# 

注意一个事实,即images文件夹不大写!这是在Windows中运行,忽略路径情况。我怀疑这可能是问题的一部分...

我真的很困惑,但我的问题了。所以这篇文章只是作为一种好奇心,尽管我无法复制它在某处从SVN转换中的行为。

+0

看起来好像git可能没有正确处理你的文件。是否有可能尝试删除文件夹名称中的空格,并查看是否可以修复它? – Devin 2013-04-11 04:24:05

+0

可能是的,简单不...我会尝试。 – nonsensickle 2013-04-11 04:27:46

+0

现在,我试图拉一个干净的存储库,但我怀疑这不会帮助。在尝试完成后,我会尝试删除空间,但版本库不小。另外,为什么git会遇到路径中的空间问题? – nonsensickle 2013-04-11 04:42:47

回答

9

我以前有过类似的问题。

对此文件或其目录中的任何位置进行了更改的大小写?

我有一个大写字母改为全小写的目录(假设它从/Foo/foo)。它给了我你所描述的所有相同的问题。

每当我修改过的文件,它给了我类似的输出:

#  modified: bar.txt 
#  modified: ../Foo/bar.txt 

我也有同样的问题提交或复位没有产生任何结果,其中。

我认为这个问题的原因是Windows文件路径是不区分大小写,但Unix上的有。由于很多像Git这样的命令行工具都是在Unix-y系统上开发的,所以它们有时无法很好地处理这种差异,并且在将文件添加为Foo/bar.txtfoo/bar.txt时可能会感到困惑。我认为这让Git认为有两个不同的文件,实际上只有一个文件。

我的最终修复是一样的你,从历史删除整个目录,然后重新添加它(永不再千变万化大小写)。这也造成了你所描述的同样古怪的地方,在它拿走之前我必须将它删除两次。

不管怎样,我知道这是不是一个明确的答案,但我既然已经能够重现问题,所以我敢肯定这是什么原因造成的(至少对我来说)。

+0

这正是我所经历的。我不知道它发生了什么,但我确信git通过SHA1校验和发现它是相同的文件,但是因为目录不同而感到困惑......无论哪种方式,你都是唯一接近的答案我有什么。我很乐意接受它作为答案,尤其是如果你能重现它。 – nonsensickle 2013-09-09 06:00:49

3

我有一个类似的问题,导致有两个文件与我的电脑同名,看到它。

消息我一直得到:

# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: images/contact_seller.GIF 
# 

它的发生是因为回购的初始提交从被格式化区分大小写,并出现在我的iMac已格式化不区分大小写错误的MacBook完成。

在区分大小写的机器,你可以看到两个文件

SwedishChef$ ls images/contact_seller* 
images/contact_seller.GIF images/contact_seller.gif 

如此混帐不得不做一些事情这不是另一台计算机上有效。

我只需重命名文件并提交这些更改。