Useful command when moving source code to a new folder or repository - sync files
Luu Vinh Loc

Luu Vinh Loc @loclv

About: I got inspired by the [Karma](https://en.wikipedia.org/wiki/Karma) principle. Karma as action and reaction: if we show goodness, we will reap goodness.

Location:
Hanoi, Vietnam
Joined:
Jul 28, 2020

Useful command when moving source code to a new folder or repository - sync files

Publish Date: Feb 26
1 0

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/
Enter fullscreen mode Exit fullscreen mode

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.
  • -n or --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".

Comments 0 total

    Add comment