2

I have a file which a modified:

$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   vw_static.vcxproj
#

even after git reset --hard and git checkout -- vw_static.vcxproj.

git diff appears to indicate whitespace (specifically, line termination) differences only.

$ git config core.autocrlf
input
$ git config --global core.autocrlf
input

There is no .git/info/attributes in this project (and no global .gitattributes either).

I don't care about line endings in this project, and I am not interested in changing this specific file (especially in committing anything related to it).

All I want is that git status reports that the tree is unmodified.

How do I get that?

sds
  • 58,617
  • 29
  • 161
  • 278
  • Do you have git modifying the files for you on push/pull? Take a look at http://git-scm.com/book/en/Customizing-Git-Git-Attributes and do a search for smudge. – Justin Wood Oct 23 '14 at 14:45
  • @JustinWood: I have no gitattributes. – sds Oct 23 '14 at 14:51
  • possible duplicate of [Unstaged changes left after git --reset hard](http://stackoverflow.com/questions/11383094/unstaged-changes-left-after-git-reset-hard) – Andrew C Oct 23 '14 at 15:08
  • @AndrewC: nope, this is a very different problem (`Changed but not updated` vs `Unstaged changes`) – sds Oct 23 '14 at 16:21
  • When I flagged that the title read completely differently. Please post the exact `git status` and `git diff` output. – Andrew C Oct 23 '14 at 16:53

2 Answers2

1

The files were probably commited with DOS line ending to the repo. Try this:

git config core.autocrlf false
rm .git/index
git reset --hard
dos2unix file1
dos2unix file2
git commit -m "Ensure files are commited with Unix line endings" file1 file2
git config core.autocrlf input
git status
sschuberth
  • 28,386
  • 6
  • 101
  • 146
0

Here is the answer for linux:

git config --global core.autocrlf true && git checkout -- vowpalwabbit/vw_static.vcxproj && git status

In fact, to be platform independent, I would have to do:

for opt in true false input; do
  git config --global core.autocrlf $opt
  for f in $(git ls-files -m); do
    git checkout -- $f
  done
  git status
done

PS. I understand that this "solution" sucks, but all I need is a work-around. I do not own the repo, and I am not in a position to introduce major changes.

sds
  • 58,617
  • 29
  • 161
  • 278
  • Setting `core.autocrlf true` on Linux just shadows the fact that files are committed with DOS line ending in the repo whereas they should not. Using `core.autocrlf` is [deprecated](http://goo.gl/9q2juW) in favor of `.gitattributes` anyway. You should do it in the [right way](http://goo.gl/nNJDTI) and normalize all files to use Unix line endings in the repo, and use a `.gitattributes` files with `*.vcxproj text eol=crlf` to check out these files with DOS line endings on *all* platforms. – sschuberth Oct 28 '14 at 08:25
  • @sschuberth: as I said in the question, I do _not_ own the repo. All I need is making the file unmodified. – sds Oct 28 '14 at 10:06
  • Sorry, I missed that. – sschuberth Oct 28 '14 at 10:09
  • I am, and I tried to undo it because of the misunderstanding, but my downvote is locked now until you edit the post. I you want to, make a dummy edit, and I'll undo my downvote. – sschuberth Oct 28 '14 at 10:13