Does rclone support .gitignore files?

What is the problem you are having with rclone?

I'm using rclone to back up a collection of Git repositories to remote storage. I'd like to exclude files that are already ignored by each repository's .gitignore file so that build artifacts, caches, and other generated files are not backed up.

I understand that rclone doesn't natively read and apply .gitignore files. Is there any supported way to make this work.

Run the command rclone version and share the full output of the command.

rclone v1.60.1-DEV
- os/version: debian 13.6 (64 bit)
- os/kernel: 6.12.94+deb13-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.2
- go/linking: dynamic
- go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone sync $SSDWORKING/_Working $WD_SOURCE/_Backup/_SSDWorkingRClone --backup-dir $WD_SOURCE/_Backup/_SSDWorkingRCloneDELETED/$(date +"%d-%m-%y_%I-%M-%S%P").bak --progress --links --create-empty-src-dirs --human-readable --log-level INFO

maybe --exclude-if-present=".gitignore"

With the potential complexity and hierarchy of .gitignore files, I suspect you'd have to write a tool to parse the .gitignore files and create a filter file. Rclone Filtering

hi @IanS, i think that --exclude-if-present=".gitignore" would work?

rclone touch ./dir1/dir2/dir3/.gitignore
rclone touch ./dir1/.gitignore
rclone touch ./dir1/file1
rclone touch ./dir1/dir2/file2
rclone touch ./dir1/dir2/dir3/file3

rclone tree . --all

/
└── dir1
    ├── .gitignore
    ├── dir2
    │   ├── dir3
    │   │   ├── .gitignore
    │   │   └── file3
    │   └── file2
    └── file1
3 directories, 5 files

rclone tree ./dir1/dir2 --all --exclude-if-present=".gitignore"

/
└── file2

0 directories, 1 files