1

If I completely delete a directory...

rm -r my_directory

...and then check out the directory...

git checkout my_directory

...how is it possible that when I then run...

git status

...I see a list of files in the directory I just checked out? How can I get the files on the server to match the latest revision of my git project? I have tried...

git reset --hard myhash

...but if I do that, and then run git status, I still see a lot of modified files "not staged for commit".

arnoldbird
  • 886
  • 1
  • 13
  • 30
  • 2
    I bet there's some eol formatting thing going on. – eftshift0 Apr 10 '19 at 16:38
  • what does `git diff` show you? – Alexey Apr 10 '19 at 16:39
  • 1
    Possible duplicate of [git status shows modifications, git checkout -- doesn't remove them](https://stackoverflow.com/questions/2016404/git-status-shows-modifications-git-checkout-file-doesnt-remove-them) – mkasberg Apr 10 '19 at 16:41
  • @eftshift0 Yes, it does appear to be an eol thing. If I run `git diff`, I see a lot of "warning: CRLF will be replaced." I will read the post @mkasberg linked to. – arnoldbird Apr 10 '19 at 16:42

1 Answers1

1

There are maaaany ways to deal with it because there are maaany options available for git to change the eol of files (I don't know who came up with this idea in the first place... it's a MESS) so in general I ask git not to touch the files and let the users take care of it. It's done this way: Add this to .gitattributes:

* -text

That should be enough to tell git to handle the files as they are. I'd do then a hard reset to make sure that the files are as they are on the revision and then I would move on with my life.

eftshift0
  • 26,375
  • 3
  • 36
  • 60