-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-wsl.sh
More file actions
29 lines (23 loc) · 744 Bytes
/
Copy pathgit-wsl.sh
File metadata and controls
29 lines (23 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# This script syncs a git repository between a Windows host and its WSL counterpart.
# WSL is slow at accessing Windows files, so this script is used to keep the Windows and its WSL counterpart in sync.
is_win=false
if [[ "$OSTYPE" == "msys" ]]; then
is_win=true
fi
cd "$(git rev-parse --show-toplevel)" ||
exit 1
name=$(basename "$PWD")
if [[ "$is_win" == true ]]; then
if ! wsl 'git -C ~/repos/ clone --origin win '"'$PWD'"; then
wsl 'git -C ~/repos/'"$PWD"' remote get-url win && git pull win'
fi
wsl_path=$(wsl 'wslpath -w ~/repos/'"$name"'')
git remote add wsl "$wsl_path"
git fetch wsl
else
if ! git remote get-url win; then
git remote add win '/mnt/c/Users/'"$USER"'/repos/'"$name"''
fi
git fetch win
fi