Created
January 24, 2019 19:02
Using rsync with .gitignore files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Rsync a git repository without .git directory, excluding files as per .gitignore | |
# -- as if, the target directory is a checkout without .git directory. | |
# | |
rsync -azP --delete --delete-excluded --filter=":- .gitignore" --exclude .git/ src/dir/path/ user@host:/dst/dir/path/ | |
# | |
# Rsync a git repository including the .git directory, excluding files as per | |
# .gitignore -- as if, the target directory is a clone. | |
# | |
rsync -azP --delete --filter=":- .gitignore" src/dir/path/ user@host:/dst/dir/path/ | |
# NOTES | |
# | |
# Rsync behaves differently if source and target paths end with '/' character or not. | |
# Above commands can be run repeatedly so that Rsync repeatedly syncs same directories | |
# without creating a new copy as a subdirectory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment