Sometimes we need to create a
tmp folder in our git repositories to store temporary stuff which we don’t really want to sync with the remote. But if you create just a
tmp directory, it won’t get synced unless you also create a file in it and ask git to track it.
There are multiple ways to solve that problem. The one that I personally use is to create a
tmp/.gitignore file with the following contents:
This tells git to:
*- ignore anything that is under this directory
!.gitignore- …except the
.gitignorefile (the very file in which these lines are written).
It is the simplest solution I could find that can be used for any folder irrespective of its name or place in the source tree!