linux sync folder by rsync

rsync

rsync -avz --delete "/home/user/A" "/home/user/B"

Explanation by SonicARG

-a Do the sync preserving all filesystem attributes

-v run verbosely

-z compress the data during the sync (transport the data in compressed mode)

--delete delete the files in target folder that do not exist in the source, /home/user/A: source folder, /home/user/B: target folder

exclude .git

--exclude='.git/'

How to use rsync to backup a directory without git subdirectory

How to sync two folders with command line tools?