Forked from bvk/gist:236de6fe34019ed8ccbe75a11379b454
Created
January 13, 2024 12:56
-
-
Save Lysander6/e2cf0a591fc5de50ac19cd7c9a24fed0 to your computer and use it in GitHub Desktop.
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