Skip to main content

2 List All Protobuf Files

You can list all of the .proto files buf is configured to use with the following command:

$ buf ls-filesgoogle/type/datetime.protopet/v1/pet.proto

This will print a list of all .proto files managed by buf per the build configuration. The build.excludes value allows you to remove certain directories from being built, but it's not generally necessary, nor is it recommended.

2.1 Remote Inputs#

The ls-files command also works with remote inputs, such as the following:

$ buf ls-files git://github.com/bufbuild/buf-tour.git#branch=main,subdir=start/petapisstart/petapis/google/type/datetime.protostart/petapis/pet/v1/pet.proto
  • The branch option specifies the branch to clone for git inputs. In this case, we're using the main branch.
  • The subdir option specifies a sub-directory to use within a git, tar, or zip input. In this case, we're targeting the start/petapis sub-directory.

We're listing the files from a git archive, so you'll notice that the result includes the start/petapis/ prefix, which is the relative filepath from the root of the git archive.

More input formats can be used in all of the buf commands. We'll explore more of these formats in the following sections.