Question:
I have a certain folder and logs
that are essential for my application to work. I would like to add it to my repository, for those who replicate don't want to keep creating the same when doing git clone
. But the detail is that the log files should not go to the repository, but only the folder.
How to do this?
Answer:
To do this in git
just add a .gitignore
file inside the desired folder and then determined that all files except the .gitignore
will be ignored inside that folder.
Structure:
logs/
.gitignore
Content of the .gitignore
that is inside the logs
folder:
*
!.gitignore
Now just use the git add logs/
command. Thus, the logs
folder will be added to the repository, but the log files in that folder will be ignored.
I usually use this a lot for uploads folder that need to exist, but I don't need the files that are in it.