brechtm / forkgit

Interact with remote git checkouts using Fork, and more!
10 stars 3 forks source link

Any idea if it's possible to use for a custom .git dir on Windows? #7

Open ian-h-chamberlain opened 1 month ago

ian-h-chamberlain commented 1 month ago

Hi, I'm starting to migrate to Windows for work (😭) and was trying to see if I could still use Fork for Windows to manage my dotfiles like I used to on macOS (for which Fork works beautifully)...

Do you know of a way to set this up so that Fork detects forkgit as a real git instance, such that it would work the same as it does on macOS? I tried a few different things, none of which seem to work so far:

Admittedly, I am a total novice when it comes to Windows and in particular I am not sure what Fork is looking for when selecting a Git instance (other than it must be a *.exe according to the file dialog). Nothing I have tried so far has made the instance "stick", so I just thought I'd ask to see if you have any ideas or thoughts about it (maybe some OS-specific stuff in the script that could be made more portable? Idk)

Thanks! If I figure anything out I will try to document it here / open a PR, in case others are trying to do the same thing!

brechtm commented 1 month ago

Wrap forkgit's bin/git script into a .exe, copy over some Git helpers like bash.exe and sh.exe

I don't think you need bash or sh. How are you "wrapping" the git script in an exe?

I think you could use something like py2exe or Nuitka to compile fotkgit's git to an executable. Have you tried that?

brechtm commented 1 month ago

I experimented a bit and got it to work for the local mode (setting git-dir in .forkgit) so far. I'll try to post details soon!

brechtm commented 1 month ago

Please check out the windows branch. You'll need to install pyinstaller and run _develexe.ps1 in a PowerShell terminal. That should build bin/git.exe, which can be selected as a Git instance in Fork.

ian-h-chamberlain commented 1 month ago

Wow, thanks for the quick response and implementation! I had been looking at implementing it with something like ps2exe to avoid bundling a whole python interpreter in the EXE, but since you've already got it working this definitely seems easier to start with!

I tried this out and it seems to work well for native Windows, but the performance was very slow when trying to use it with a repository stored on the WSL filesystem, since git.exe accessing files inside WSL is known to be slow (see e.g. https://markentier.tech/posts/2020/10/faster-git-under-wsl2/)

I tried hacking around your changes to improve it specifically for WSL and landed on this: https://github.com/brechtm/forkgit/compare/windows...ian-h-chamberlain:forkgit:windows There's probably some overhead from calling wsl.exe for every git command, but it seems a lot faster vs git.exe at least. I'm happy to clean it up a bit and make a PR if you'd like.

Thanks again, this should really help me while trying to migrate all of my dotfiles over to Windows!

brechtm commented 1 month ago

I'm happy to clean it up a bit and make a PR if you'd like.

Yes, please do. I'll merge it into the windows branch. I can test drive the changes on MacOS to see whether they break anything before I merge it into the master branch.

You don't happen to be interested in trying to get remote (SSH) repositories working in Windows by any chance? πŸ˜‰

brechtm commented 1 month ago

You don't happen to be interested in trying to get remote (SSH) repositories working in Windows by any chance? πŸ˜‰

I wanted to see how easy this would be, and it turns out: very! πŸ˜„ The windows branch will now also handle remote repositories. You'll need to install Fork 1.86 (and immediately disable auto-updating) and create an empty .git/config file locally (in addition to the .forkgit configuration).