如何摆脱 git 中的虚假更改?
我是 PortableGit 1.7.0.2 的快乐用户。今天我想从 GitHub.com 存储库中提取项目更改,所以我执行了 git pull 。它失败并显示以下消息:错误:您对“main.rb”的本地更改将被合并覆盖。正在中止。
。我不关心本地更改,所以我输入了 git reset --hard HEAD
(git clean
从这里也没有帮助),但它不起作用。当询问 git status 时,我仍然能够看到文件已修改。 git diff
显示文件的每一行都已被修改,而 git diff -b
显示没有任何差异,所以我猜这是一个行结束问题。这很奇怪,因为代码仅是从 Windows 机器推送的。
无论如何,问题是:如何忽略本地的虚假更改并与远程存储库中的最新更改合并?
I'm a happy user of PortableGit 1.7.0.2. Today I wanted to pull a project changes from GitHub.com repository, so I did git pull
. It failed with the following message: error: Your local changes to 'main.rb' would be overwritten by merge. Aborting.
. I didn't care about the local changes so I typed git reset --hard HEAD
(git clean
from here didn't help neither), but it didn't work. When asked for git status
I was still able to see the file as modified. git diff
showed me that each line of the file has been modified, while git diff -b
showed no differences at all, so I guess this is a line ending issue. Which is strange because the code is only pushed from Windows machines.
Anyway, the question is: how can I ignore the local, bogus changes and merge with the latest changes from the remote repository?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您是否尝试过
git clean -f
(注意“-f
”)?从
git config
手册页:其次,您是否将
autocrlf
设置设置为 false 正如我在这个问题中提到的?(即使从 Windows 机器推送到 Windows PC,带有 Unix eol 的文本文件也会转换为 Windows eol)
考虑到这两点,您应该能够拉取。
First, did you try a
git clean -f
(note the '-f
')?From
git config
man page:Second, did you set your
autocrlf
setting to false as I mention in this question?(even if pushed from a Windows machine to a Windows PC, a text file with Unix eol would be converted to Windows eol)
With those two points taken care of, you should be able to pull.