开发者

How to get rid of bogus changes in git?

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?


First, did you try a git clean -f (note the '-f')?
From git config man page:

clean.requireForce

A boolean to make git-clean do nothing unless given -f or -n. Defaults to true.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜