How to use rsync on Git Bash

Seunghyun Chae
3 min readJan 3, 2021

--

Here’s a guide on how to use rsync on Git Bash in the Windows operating system. (Installed using the Windows 10 October 2020 Update version iso)

1. Install zstd

zstd(Zstandard) is a compression algorithm by facebook that we’ll be using from now on. First download a zstd release zip file from the below link.

https://github.com/facebook/zstd/releases/download/v1.4.4/zstd-v1.4.4-win64.zip

Then make a directory wherever you want to keep the zstd executable. (I just kept it in my Downloads directory) It might be a good idea to keep it at a more basic directory (like root).

cd ~/Downloads
mkdir zstd
mv zstd-v1.4.4-win64.zip ./zstd
cd zstd
unzip zstd-v1.4.4-win64.zip
echo "alias zstd=\"/c/Users/[USER_NAME]/Downloads/zstd/zstd.exe\"" >> ~/.bashrc
source ~/.bashrc

By executing the above sequence, we can use the zstd. We can check whether everything went well by executing ‘zstd -h’. It should print out the below messages.

zstd -h result

Now we can use the ‘zstd -d’ command to decompress pkg.tar.zst files we will download later on.

2. Get rsync.exe

All the required files can be acquired from http://repo.msys2.org/msys/x86_64/ (will be used in step 3 as well)

From the above site, download the latest rsync compressed file. (in my case it was rsync-3.2.3–1-x86_64.pkg.tar.zst)

mv ~/Downloads
mkdir rsync
mv rsync-3.2.3-1-x86_64.pkg.tar.zst ./rsync
cd ./rsync
zstd -d rsync-3.2.3-1-x86_64.pkg.tar.zst
tar -xvf rsync-3.2.3-1-x86_64.pkg.tar

The rsync.exe we want to find resides in ~/Downloads/rsync/usr/bin directory.

mv ~/Downloads/rsync/usr/bin/rsync.exe C:\Program Files\Git\usr\binecho "alias rsync=\"/usr/bin/rsync.exe\"" >> ~/.bashrc
source ~/.bashrc

After executing the above sequence, if you execute ‘rsync’, an error message such as “error while loading shared libraries: msys-zstd-1.dll: cannot open shared object file: No such file or directory occurs”.

3. Acquiring the missing dll files

So, to normally execute rsync, we require two additional dll files, libzstd and libxxhash.

  1. libzstd

Download the latest libzstd compressed file. (in my case libzstd-1.4.8–1-x86_64.pkg.tar.zst)

mv ~/Downloads
mkdir libzstd
mv libzstd-1.4.8-1-x86_64.pkg.tar.zst ./libzstd
cd./libzstd
zstd -d libzstd-1.4.8-1-x86_64.pkg.tar.zst
tar -xvf libzstd-1.4.8-1-x86_64.pkg.tar

2. libxxhash

Download the latest libxxhash compressed file. (in my case libxxhash-0.8.0–1-x86_64.pkg.tar.zst)

mv ~/Downloads
mkdir libxxhash
mv libxxhash-0.8.0-1-x64_64.pkg.tar.zst ./libxxhash
cd ./libxxhash
zstd -d libxxhash-0.8.0-1-x64_64.pkg.tar.zst
tar -xvf libxxhash-0.8.0-1-x64_64.pkg.tar

Then copy/move the above acquired dll files to where we copied/moved the rsync.exe file, to C:\Program Files\Git\usr\bin.

mv ~/Downloads/libzstd/usr/bin/msys-zstd-1.dll C:\Program Files\Git\usr\bin
mv ~/Downloads/libxxhash/usr/bin/msys-xxhash-0.8.0.dll C:\Program Files\Git\usr\bin

After the above 3 steps, you should be able to use rsync on Git bash. (executing ‘rsync -h’ should return the below messages)

rsync -h result

(Any comments or constructive criticisms are always welcome!)

--

--

Seunghyun Chae

Ph.D student majoring in Software Verification, specifically NN verification