3

I have tried to git add a file. But when I check git status, the file is still marked as "Changes not staged for commit". I have read many similar questions and I have tried everything:

  • make sure I am in the right repository
  • make sure there is no other .git in any folders (no submodules)
  • make sure there is no corresponding entry in .gitignore (neither local nor global/system)
  • make sure there is no upper/lower-case mistake
  • make sure to try all variations of git add (-A, -u, ., *)

Still nothing seems to work

That is what it looks like:

enter image description here

Any ideas, what else to try or what I may have missed?

Thanks for any help in advance!

EDIT:

This whole _build/ folder is created, when I run jb-build systemtechnik-fuer-energieeffizienz. It contains (mainly, besides some other stuff, like these .doctree documents) the html output of a jupyter book created by all these jupyter notebooks in the nb/ folder (see here jupyter book). So it is not a submodule (in my understanding submodules have an own .git folder, however, inside _build/ there is no such folder)

  • The output of git rev-parse --show-toplevel is:

    C:/Users/andre/Documents/GitLab/OER4EE_SYE/systemtechnik-fuer-energieeffizienz

  • git version is git version 2.24.0.windows.2

  • the output of git diff -- _build/.doctree/SYE.doctree is:

    just a blank line

  • the output of git check-attr -a _build/.doctree/SYE.doctree is:

    just another blank line

Andre
  • 321
  • 1
  • 12
  • What is the output of `git rev-parse --show-toplevel`? – Matt Jul 04 '21 at 14:08
  • What *is* `_build/.doctrees/SYE/doctree`? Is it a submodule? (If so, you have a rather old version of Git.) (Note: your question would be *far* more readable if it were not largely an image of text. See [ask].) – torek Jul 04 '21 at 14:11
  • 1
    Have you trie `git add _build/.doctrees/SYE.doctree`? If that doesn‘t work either, check if you execute the commands in the git-root folder (directory, where the `.git` folder is) – SwissCodeMen Jul 04 '21 at 14:12
  • Also : what shows up in the diff with the indexed version `git diff -- _build/.doctree/...` ? – LeGEC Jul 04 '21 at 14:41
  • git can apply some modifications on a file when you run `git add`, if it has a `filter` attribute defined in `.gitattributes`. You can check your `.gitattributes` file in your repo, or run `git check-attr -a _build/.doctree/SYE.doctree` to see if any attribute applies to this file. – LeGEC Jul 04 '21 at 14:54
  • @torek: thank you for the hint! I will try to improve my question! Edit ahead – Andre Jul 05 '21 at 04:32
  • Aha. Probably the doctree file has some otherwise-invisible character(s) (newlnes, carriage returns, etc) that provide an end-of-line that your Windows system doesn't like very much, so that your Git is converting these to pure-CRLF line endings (generally preferred on Windows though there are exceptions). This is leading to a file that doesn't "add" properly. But, as in VonC's answer, the `_build` output should probably never be committed in the first place, rendering any EOL issues irrelevant. – torek Jul 05 '21 at 10:52

1 Answers1

2

This whole _build/ folder is created, when I run jb-build systemtechnik-fuer-energieeffizienz

Then it should be ignored:

cd C:/Users/andre/Documents/GitLab/OER4EE_SYE/systemtechnik-fuer-energieeffizienz
echo build/>>.gitignore
git rm --cached -r build/
git check-ignore -v -- build/.doctrees/SYE/doctree

Assuming doctree is a file, the last git check-ignore command should return a .gitignore rule, and git status should not display it, ever.

So it is not a submodule (in my understanding submodules have an own .git folder, however, inside _build/ there is no such folder)

A submodule would not have a .git/ subfolder, but:

  • would be declared in a .gitmodules file in the parent repository root folder
  • would be in $GIT_DIR/modules/_build, meaning under the main parent repo own .git/modules folder
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Sorry for the late reply, I have commletely forgotten about this. Thanks for your answer! The problem was solved as you have proposed. I didn't want to change the `.gitignore` because I have just forked this repo (but the owner did the change) and now it works! – Andre Aug 18 '21 at 16:26