-1

I'd like to revert a file to the version of the last commit, but it is still displayed as modified after the checkout.

This is the situation before:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   doc/slides/slides.pdf
...

Then I want to revert it:

$ git checkout doc/slides/slides.pdf
Updated 1 path from the index

Afterwards it is still displayed as modified:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   doc/slides/slides.pdf
...

I even tried to remove it and use Git to check it out again, but it's still displayed as modified. git diff says:

Binary files a/doc/slides/slides.pdf and b/doc/slides/slides.pdf differ

I'm using pre-commit (with hooks) and DVC. But I doubt this shouldn't make a difference here.

lumbric
  • 7,644
  • 7
  • 42
  • 53
  • Have you tried `use "git restore ..." to discard changes in working directory`? – mkrieger1 Jan 15 '21 at 13:46
  • Does this answer your question? [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) – mkrieger1 Jan 15 '21 at 13:48
  • @mkrieger1 no, to all questions :( It's Linux, so case sensitive, git restore doesn't change anything and it's a binary file so line endings also won't matter. – lumbric Jan 15 '21 at 13:53
  • Note that you can still set Git up to modify a file during extraction from index to work-tree, even on Linux. It's not exactly *normal* to do that, though. If you didn't do that, it shouldn't be happening. – torek Jan 16 '21 at 06:22

1 Answers1

0

Okay, this was really stupid. Nothing to do with Git.

I still had pdflatex running in the background with a file watcher without noticing it. So the PDF got recreated every time I reverted it.

lumbric
  • 7,644
  • 7
  • 42
  • 53