My original instructions to get rsync working with Git for Windows were quite a bit outdated, so I've revamped this answer for mid-2023 to cover MSYS2's switch to zstd
and the additional dependencies required for rsync. The primary issue is that MSYS2 now compresses most packages (including zstd, rsync, and dependencies) using zstd, but zstd isn't included in the base environment. Because of this we can't get zstd from the MSYS2 repository--but we can get it directly from the zstd Github releases where it is a zip archive rather than zst. The basic idea for getting rsync working that I originally came across in this post is still the same, but due to the above mentioned issues it requires a bit more work. The whole process is still easily doable once we know everything required.
Below are commands to:
- download the zstd binary to use in extracting further packages
- download, extract, and place the rsync binary and it's dependencies in the correct bin folder
These steps have been tested on a clean install of Windows 11 with only the latest Git for Windows installed (should work for Windows 10 as well). No other dependencies should be required to complete the steps.
As always, examine what you paste into a terminal and use at your own risk
Step 1: zstd requirement
If you have an environment that doesn't already support extracting archives compressed with zstd (such as with Git for Windows), the easiest way is probably to download the latest zstd Windows binary directly from the ztsd release page: https://github.com/facebook/zstd/releases. If you already have zstd available and in your sourced path then skip to step 2 (and you may need to adjust the zstd binary location in the script).
Copy the below lines into a Git Bash terminal after adjusting below variables for latest source locations, versions, and your preferred download location:
working="/c/temp-downloads"
zstd_url="https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-v1.5.5-win64.zip"
mkdir -p "$working"
curl -L -o "$working/zstd.zip" "$zstd_url"
unzip -j "$working/zstd.zip" "*/zstd.exe" -d "$working"
Step 2: Downloading compatible rsync and dependency binaries, extracting, and placing in proper location
Copy the below lines into an admin Git Bash terminal after adjusting below variables for latest source locations, versions, and your preferred download location. The terminal must be running as admin if the destination bin folder is in a location requiring privileged access.
# If you downloaded zstd above, make sure your working folder is the same as where the zstd binary is located
working="/c/temp-downloads"
# Set the location of the Git usr/bin folder (under normal installations we can simply use /usr/bin because the MSYS2 root is the Git installation folder)
git_usr_bin_folder_location="/usr/bin"
rsync_url="https://repo.msys2.org/msys/x86_64/rsync-3.2.7-2-x86_64.pkg.tar.zst"
libxxhash_url="https://repo.msys2.org/msys/x86_64/libxxhash-0.8.1-1-x86_64.pkg.tar.zst"
mkdir -p "$working"
curl -L -o "$working/rsync.tar.zst" "$rsync_url"
curl -L -o "$working/libxxhash.tar.zst" "$libxxhash_url"
tar -I "$working/zstd.exe" -xvf "$working/rsync.tar.zst" --directory="$working"
tar -I "$working/zstd.exe" -xvf "$working/libxxhash.tar.zst" --directory="$working"
cp -a "$working/usr/bin/." "$git_usr_bin_folder_location"
That should be all you need to get rsync working as everything else necessary should already be included in the base Git for Windows MSYS2 environment. You can now clean up the contents of the working folder. Hopefully at some point zstd will be included in the base environment and the extra step of acquiring it won't be needed, but it is what it is for now.
If you want to also use Pageant authentication with rsync over ssh, the ssh-pageant binary is already installed in Git for Windows and all you need to do is add a small bit to your ~/.bashrc
or ~/.bash_profile
file (see ssh-pageant usage section and Git for Windows wiki). I've modified it specifically for use with the Git for Windows environment and enhanced it with some detection for a missing socket file:
# ssh-pageant allows use of the PuTTY authentication agent (Pageant)
SSH_PAGEANT="$(command -v ssh-pageant)"
if [ -S "$SSH_AUTH_SOCK" ]; then
PAGEANT_SOCK=$SSH_AUTH_SOCK
else
PAGEANT_SOCK=${TEMP:-/tmp}/.ssh-pageant-$USERNAME
fi
if [ -x "$SSH_PAGEANT" ]; then
eval $("$SSH_PAGEANT" -qra "$PAGEANT_SOCK")
fi
unset SSH_PAGEANT
unset PAGEANT_SOCK