Working on a local Git (cloned) repository, I have created a branch and placed .gitignore
file within it to exclude few directories from git commit
. It works just fine, but after switching to a different branch, those directories (the excluded ones) appear in it (on the branch which does not include those directories).
Is it a normal Git behavior? If so, what is the best practice to avoid the issue above?
The .gitignore
file is a file in the repository just like any other. So if you create a new .gitignore
file, commit it on one branch, then switch to another, the .gitignore
file will disappear. This is normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With