1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[WSL2] `git`コマンドで,/mnt/以下ではWindows版git,それ以外ではLinux版gitを利用したい

Last updated at Posted at 2024-03-04

以下を .bash_aliases に追加することで解決した。

alias windows-git='/mnt/c/Program\ Files/Git/bin/git.exe'
alias linux-git='/bin/git'

git-selector () {
    local currentDir=$(pwd -P | cut -d'/' -f2)
    if [ "$currentDir" = "mnt" ]; then
        windows-git "$@"
    else
        linux-git "$@"
    fi
}

alias git=git-selector

PulseSecureを利用していて、WSL2でVPNを通ることができない環境なので必要になった。

同様の状況下なら、他のコマンドでも応用が効くと思う。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?