Useful command when moving source code to a new folder or repository
rsync (remote sync) is a fast, versatile command-line utility for Unix-like systems, used to synchronize files and directories locally or across networked computers.
It can update, create, and delete files.
rsync -av --exclude={'node_modules','.git','logs'} --exclude-from='.gitignore' ./ /path/to/destination
Explain
-
rsync: sync files from one folder to another -
--exclude={'node_modules','.git','logs'}: exclude some folders -
--exclude-from='.gitignore': exclude files in.gitignore -
-a(archive): Preserves permissions, symlinks, and timestamps (crucial for backups). -
-v(verbose): Shows detailed output. -
-z(compress): Compresses data during transfer. -
--delete: Deletes files in the destination that are not present in the source. -
-nor--dry-run: Simulates the action without actually copying or deleting files. -
./: current folder -
/path/to/destination: destination folder - Note: A trailing slash (/) on the source directory means "copy the contents of this directory," while omitting it means "copy the directory itself".
Top comments (0)