non*_*kle 12 windows git png mingw msysgit
我按照本教程将SVN存储库转换为Git .现在似乎无法提取此答案中建议的子存储库.
原谅长篇文章,但大部分文本都是格式良好的git输出.
操作系统:Windows 8命令行:MinGW Git版本:1.8.1.msysgit.1
除非您有一个干净的暂存区域且没有修改过的文件,否则提取子存储库的过程似乎不起作用.
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")
Run Code Online (Sandbox Code Playgroud)
这不起作用,但我真的不在乎我是否承诺,所以我接下来会尝试.
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")
Run Code Online (Sandbox Code Playgroud)
通过跳过暂存提交不起作用,所以让我们先尝试暂存它.
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")
Run Code Online (Sandbox Code Playgroud)
不行,所以我很难过......去找一个更聪明的人.
我是git的新手,但我很熟悉Hg,并且已经阅读了这个在线教程,让我自己开始.
我完全可能搞砸了一个简单的命令.
已经尝试过: 我四处寻找解决我的特定问题的方法,但运气不佳.我偶然发现了这个似乎相关的答案,但并没有完全解决我的问题.
编辑:可能有趣的事情
这是令我困惑的部分.我刚才把这个仓库推到了一个在线仓库.在一个新的克隆之后,repo仍然认为文件被修改(即git status
返回相同的结果,并且我已经git config --global core.autocrlf false
通过运行设置和验证,git config --global core.autocrlf
其确实返回false).
编辑2:发现修复,但问题仍未解释 我已设法通过简单地从系统,暂存区域中删除文件然后提交更改来修复存储库.在此之后获取文件我只是将其复制回来并将其提交到存储库.
这个问题虽然已经解决,但只会让我更加困惑.
当我正在玩删除文件时,我注意到如果我将存储库重置为HEAD,其最后一次提交已删除文件,git status将指示没有任何更改,并且文件未被跟踪但文件将被还原在我工作的树上.考虑到它被标记为在git中删除,这很奇怪......
只有消除了第二遍后,即使混帐不再记得它,我才设法实际删除它,这样git reset
并git reset --hard
不会恢复该文件.
如果有人可以解释我是如何进入这种状态的,如果它是git或正常行为中的错误,我将非常感激.
我的怀疑
我已经丢失了我使用的命令序列,但发生的事情是这样的:文件是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
#
Run Code Online (Sandbox Code Playgroud)
请注意该images
文件夹不是大写的事实!这是在Windows中运行忽略路径的情况.我怀疑这可能是问题的一部分......
我真的很困惑,但我的问题已经消失了.所以这篇文章只是作为一种好奇心,尽管我无法复制它在SVN转换过程中的行为.
我有一段时间有类似的问题.
是否对此文件或其所在的目录进行了大写更改?
我有一个大写字母的目录,该大写字母被改为全部小写(让我们说它从那里/Foo
开始/foo
).它给了我你所描述的所有相同的问题.
每当我修改一个文件时,它给了我类似的输出:
# modified: bar.txt
# modified: ../Foo/bar.txt
Run Code Online (Sandbox Code Playgroud)
我也有同样的问题,提交或重置没有产生任何结果.
我认为问题的原因是Windows文件路径不区分大小写,但Unix文件路径不区分大小写.由于许多像Git这样的命令行工具都是在Unix-y系统上开发的,所以它们有时候不能很好地处理这种差异,并且当文件被添加为Foo/bar.txt
和时会感到困惑foo/bar.txt
.我认为这让Git认为有两个不同的文件,实际上只有一个.
我的最终修复与您的相同,从历史记录中删除整个目录,然后重新添加它(并且永远不会再次更改大小写).这也引起了你所描述的同样的怪异,我必须在它花了两次之前删除它.
无论如何,我知道这不是一个明确的答案,但我已经能够重现这个问题,所以我很确定是什么导致了它(至少对我而言).