0

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?

sev
  • 1,500
  • 17
  • 45

1 Answers1

1

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.

DominicT
  • 388
  • 1
  • 9
  • I don't understand how your answer is supposed to address my issue... What are the concrete steps you suggest I take and what is the rational behind them? – sev Apr 25 '23 at 10:31
  • I've updated my answer, please do check. – DominicT Apr 25 '23 at 17:44
  • Hi thanks for the clarification. A) When I don't put a .gcloudignore file it just uses the standard one which treats **/package.json in the unexpected way I mentioned. B) Also with the .gcloudignore it treats the **/package.json in a way which I would not expect. Why is that happening? – sev Apr 25 '23 at 17:53