Answer the question
In order to leave comments, you need to log in
Git ignoring the contents of a folder but not the folder itself?
There are several projects that periodically roam between developers. Yii framework at the core. To work in it, the presence of the /protected/runtime folder is required, however, the contents of this folder do not matter. You can shove a gitignor into the folder itself with the following content:
*
!.gitignore
However, it is required for several folders to create these folders, but they must be empty, even without gitignore inside
Answer the question
In order to leave comments, you need to log in
There is one solution.
Put .gitattributes with export-ignore in the directory.
And for production, don’t upload the entire git repo, but do an export (via git-archive).
On my test bench, this is actively used - by push to the repository, the hook executes git-archive + tar x in the desired directory.
We usually do
.gitignore:
/tmp/
touch tmp/.keepme
git add tmp/.keepme # there still seems to be some key for force to be specified
Or is the task to leave the folders _generally_ empty?
.gitignore can be completely empty, all files except .gitignore will be ignored.
There is no other way to add a folder to git - git does not store files / folders, but stores file diffs, this requires files.
If you need absolutely empty folders, install install.sh (or use phing as on an adult project), of course, .gitignore in the project root should contain a list of all empty folders. Anyway, there is something else to do - set permissions, fill in the base ...
You need to do something like this...
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
The Internet is full of answers .
The official site's FAQ explains that Git only works with files, so it's not possible to spy on an empty folder.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question