I don't know if this is a bug or intended, but with Github Desktop the files specified on .gitignore
are carried over to any other branch I switch to and it asks me to commit those files. One fix is to have the same .gitignore
file on all other branches, but that will clutter up the environment.
Eg:
node_modules
in .gitignore
.node_modules
is carried over and asks to be committed.You generally want to have the same .gitignore
file in all branches. If you want to ignore node_modules
in a particular branch, you probably don't want to check it in while on other branches.
Since Git only honors the .gitignore
file in the working tree and not the ones in other branches, you're seeing that branch 2, which is missing it, has your node_modules
directory not ignored. As a result, they show as untracked files, and GitHub Desktop suggests that they be committed.