【发布时间】:2012-09-20 19:15:54
【问题描述】:
我创建了一个包含单个文本文件的测试存储库来测试交互式登台,特别是手动编辑差异。但无论我尝试什么,git 总是返回错误:patch does not apply。奇怪的是,即使我关闭文本编辑器而不更改任何内容,它也会这样做。如果我只是接受有问题的大块而不请求编辑,我可以毫无问题地提交。
刚开始使用 Git,所以很可能我搞砸了。这就是我所做的:
$ create 'test' directory
$ open shell inside the directory
$ git init
$ create 'newfile.txt' inside the directory
$ git add newfile.txt
$ git commit -m 'first commit'
$ open newfile.txt, add 'line 1', save & exit
$ git add newfile.txt -e
$ editor comes up, close it without any modifications
$ error: newfile.txt: patch does not apply
(在 Windows 上使用 Win 7 64 和 Git。)
【问题讨论】:
-
不知道这是不是换行问题? CRLF vs LF?
-
我认为 Ben 的猜测是正确的。在我的 linux 系统(使用 git 版本 1.7.11.4)上运行命令
mkdir /tmp/test; cd /tmp/test; git init; touch newfile.txt; git add newfile.txt; git commit -m 'first commit'; echo line 1 >> newfile.txt; env EDITOR=gedit git add newfile.txt -e不会产生错误。 -
你是对的, git config --global core.autocrlf false 成功了。谢谢!
标签: git diff interactive staging