How to create .local.gitignore that is not synchronized with Git?
-
Create the
.local.gitignorefiletouch .local.gitignore -
Add it to
.git/info/exclude(so Git applies it locally)echo ".local.gitignore" >> .git/info/exclude -
Configure Git to treat
.local.gitignoreas.gitignoregit config --local core.excludesfile .local.gitignore
Now .local.gitignore will work like a regular .gitignore, but only for you.
How does it work?
.local.gitignoreis not added to the repository.- It is applied only locally on your computer.
- It works like
.gitignore, but other developers don’t have it. - Git does not see this file thanks to
.git/info/exclude.
Now you can add local files to it:
echo "my-secret-file.txt" >> .local.gitignore
echo "debug_logs/" >> .local.gitignore