jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.65k stars 1.84k forks source link

WSL and Lazygit #1330

Open samaursa opened 3 years ago

samaursa commented 3 years ago

Is your feature request related to a problem? Please describe. With WSL it is recommended to use git.exe instead to speed up certain operations. For example, in Lazygit, when trying to do a refresh, it takes a few minutes rather than just a second or two.

Describe the solution you'd like Be able to specify the git executable e.g. "/mnt/c/Program Files/Git/bin/git.exe"

Describe alternatives you've considered N/A

Additional context Would love to use Lazygit but the above is preventing me from using it in a WSL environment.

jesseduffield commented 3 years ago

This makes sense. The solution would be to find all the places we're calling git blah in the codebase and have the git part substituted for a variable, where that variable can be set by the user in the lazygit config.

gthau commented 3 years ago

I'm not experiencing such issue working with lazygit in WSL environment.

when trying to do a refresh, it takes a few minutes rather than just a second or two.

What do you mean by "do a refresh"? fetch / pull? something else?

Is your working tree on a Windows partition (e.g. /mnt/c)? Maybe I don't experience your problem because I keep my code on wsl ext4 partition (on the Hyper-V vhdx file that backs the WSL filesystem). I think this is the recommended way to proceed.

In my experience, using Windows's git.exe for files on the linux partition has downside such as it changes the chmod of all executables (e.g. .sh files) to 777 and lists those in the changes to be staged, which is really annoying.

samaursa commented 3 years ago

In this context, by "do a refresh" I simply meant getting the status (i.e. waiting for the log tree to show up)

anesabml commented 2 years ago

There is a workaround for this issue and that is to install LazyGit on whatever distro you have running on wsl2 and on Windows too, when you are on NTFS file system use lazygit.exe else use lazygit and if you want you can have a function like this on your ~/.profile or ~/.zprofile:

# checks to see if we are in a windows or linux dir
function isWinDir {
  case $PWD/ in
    /mnt/*) return $(true);;
    *) return $(false);;
  esac
}
# wrap the lazygit command to either run windows lazygit or Linux lazygit
function lazygit {
  if isWinDir
  then
    lazygit.exe "$@"
  else
    lazygit "$@"
  fi
}