gcloud alpha topic gcloudignore

NAME
gcloud alpha topic gcloudignore - reference for.gcloudignore files
DESCRIPTION
(ALPHA) Several commands ingcloud involve uploading the contents ofa directory to Google Cloud to host or build. In many cases, you will not wantto upload certain files (i.e., "ignore" them).

If there is a file called.gcloudignorewithin thetop-level directory being uploaded, the files that it specifies(see "SYNTAX") will be ignored.

Gcloud commands may generate a .gcloudignore file; see the individual commandhelp page for details.

The followinggcloud commandsrespect the.gcloudignore file:

To globally disable.gcloudignore parsing (including defaultfile-ignore behavior), run:

gcloudconfigsetgcloudignore/enabledfalse

The default content of the generated.gcloudignore file, which canbe overridden with--ignore-file, is as follows:

.gcloudignore.git.gitignore
EXAMPLES
This.gcloudignore would prevent the upload of thenode_modules/ directory and any files ending in~:
/node_modules/*~

This.gcloudignore (similar to the one generated when Git files arepresent) would prevent the upload of the.gcloudignore file, the.git directory, and any files in ignored in the.gitignore file:

.gcloudignore# If you would like to upload your .git directory, .gitignore file or# files from your .gitignore file, remove the corresponding line below:.git.gitignore#!include:.gitignore
SYNTAX
The syntax of.gcloudignore borrows heavily from that of.gitignore; seehttps://git-scm.com/docs/gitignoreorman gitignore for a full reference.

Each line in a.gcloudignore is one of the following:

  • pattern: a pattern specifies file names to ignore (or explicitlyinclude) in the upload. If multiple patterns match the file name, the lastmatching pattern takes precedence.
  • comment: comments begin with# and are ignored (see"ADVANCED TOPICS" for an exception). If you want to include a# atthe beginning of a pattern, you must escape it:\#.
  • blank line: A blank line is ignored and useful for readability.

Some example patterns follow; see the full reference (https://git-scm.com/docs/gitignoreorman gitignore) for details.

To ignore any file namedfoo, and any file in the root of theupload directory namedbar:

foo/bar

To ignore any file starting withfoo, ending withbar,or starting withbaz and ending withqux:

foo**barbaz*qux

To explicitly include any file namedfoo (useful iffoo was excluded earlier in the file) and ignore a file named!bar:

!foo\!bar

To ignore any directoryfoo and all its contents (though not a filefoo), any filebaz, and the directoryquxand all its contents:

foo/**/bazqux/**
ADVANCED TOPICS
In order to ignore files specified in the gitignore file, there is a specialcomment syntax:
#!include:.gitignore

This will insert the content of a.gitignore-style file named.gitignore at the point of the include line. It does not recurse(that is, the included filecannot#!include anotherfile) and cannot be anywhere but the top-level directory to be uploaded.

To display files that will be uploaded run:

gcloudmetalist-files-for-upload
NOTES
This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudtopicgcloudignore
gcloudbetatopicgcloudignore

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-22 UTC.