Why do I manually need to add !package.json in .gcloudignore when setting **/package.json in .gitignore

170 views Asked by At

I would like both git and gcloud to ignore all package.json files except the one in the base folder. I've set **/package.json in the .gitignore file which works fine except that gcloud also ignores the package.json in the base directory.

I have solved this by creating a .gcloudignore file with the content:

.git
.gitignore

#!include:.gitignore
!package.json

As I want exactly the same behaviour from gcloud and git I would have expected to be able to only set the .gitignore file. Am I doing something wrong?

1

There are 1 answers

3
DominicT On

The reason why .gcloudignore is needed to ignore files/directory is that it is the only required file if you want to ignore files when you deploy inside the gcloud environment. Basically these files have similar functions, .gcloudignore only works within the gcloud environment.

The syntax below should be used inside .gcloudignore so that it will exclude all the files or directory inside your .gitignore file those files/directory:

#!include:.gitignore

You may check this documentation on .gcloudignore for additional information.

Hope this helps.