D
D
Dmitry Sonko2012-08-22 10:12:50
git
Dmitry Sonko, 2012-08-22 10:12:50

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

7 answer(s)
M
mithraen, 2012-08-22
@SonkoDmitry

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.

M
mjr27, 2012-08-22
@mjr27

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?

C
corristo, 2012-08-22
@corristo

git basically doesn't work with empty folders

D
denver, 2012-08-22
@denver

.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 ...

S
sdevalex, 2012-08-22
@sdevalex

You need to do something like this...

# Ignore all logfiles and tempfiles. 
/log/*.log
/tmp

A
akral, 2012-08-22
@akral

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.

D
Dmitry Sonko, 2012-08-22
@SonkoDmitry

Resolved, no longer relevant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question