Search code examples
gitversion-controlgit-addgit-statusgit-stage

unable to add files with git add


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


Solution

  • 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