Josh
Josh

Reputation: 12791

rsync betwen repositories the files that git does not track

Say I have a git directory in path_A in a machine A with .gitignore files all over the place. I have a copy of this repository in a machine in path_B in a different machine B.

I would like to rsync all files from path_A to path_B that are not tracked by git so that both machines have effectively the same files (e.g. including binaries). Is there a relatively simple way of doing this?

Upvotes: 0

Views: 951

Answers (1)

1615903
1615903

Reputation: 34849

You can give 2 arguments to rsync - first exclude all files: --exclude="*" then use include-from with the .gitignore file as argument: --include-from='.gitignore'

The first exclusion makes rsync ignore all by default. The latter inclusion reads include patterns from a file called .gitignore, which leads to all gitignored files being included in the rsync.

Upvotes: 1

Related Questions