pmiranda
pmiranda

Reputation: 8420

git, checkout is not removing the file

I don't get why by doing git checkout filename is not working.

Here are the steps. First, in the terminal:

enter image description here

Now git status:

enter image description here

I get a bunch of files that are modified. When I try with each of those files to checkout them I get this (I'll do an example with only 2 files):

enter image description here

Everything seems fine, but when I do a git status I can see those file again on the modified list:

enter image description here

So, I don't get. The only thing that came in mind is that another exe is reading and writing those files at every moment, but why not other files? I have a lot of files under src/public. This happen too if I restart (Windows) and the very first thing that I try is this (without opening IDE's or whatever) If I delete those files, I will remove the from the branch, I can't do that, I just want to remove them as modified. Any idea?

Edit: My last tries according to @VonC answer were:

274  git restore transpiler.sh
275  git config --global core.autocrlf false
276  git checkout transpiler.sh
277  git restore transpiler.sh
278  git checkout -- transpiler.sh
279  git checkout transpiler.sh
280  git status

still there the file...

Upvotes: 0

Views: 345

Answers (1)

VonC
VonC

Reputation: 1323203

If the issue persists with git restore aFile (which is easier than git checkout -- aFile, to avoid to specify to checkout that aFile is a file, not a branch), then check your configuration

git config core.autocrlf

I prefer making sure it is set to false, to avoid any automatic eol (end-of-line) conversion.
Then try git restore + git status again.


The OP pmiranda points out in the comments to the other cause of automatic change: core.filemode, that I explained here.

Tells Git if the executable bit of files in the working tree is to be honored.

The remedy is:

git config core.filemode false 

This avoids:

old mode 100755 
new mode 100644

Upvotes: 1

Related Questions