Search code examples
linuxgitrsync

rsyncing git project folder


I need to rsync a git project folder and I'm using the follow rsync flags -r -a -v -u -W but when I run git status on the destination folder it does not match with git status on the source (I get modified/deleted files that were not actually touched).

Why is this happening? And how to make it work as intended?


Solution

  • From rsync manual:

    -u, --update                skip files that are newer on the receiver
    

    So it may skip files...

    Use git

    Anyway, there is no need for rsync when you have the source dir versioned.

    Clone the folder

    cd /my/destination
    git clone /my/source/repo
    

    Sync the folder

    cd /my/destination/repo
    git fetch