reddit / emacs

Using magit on windows

aimebertrand · 2022-06-02 09:12
Hey Emacs people, I found myself needing/having to use windows (not very happy about it). I have parsed this Reddit, the google, the stack... and haven't found a solution to my 2 issues. 1. I cannot edit/add commit messages: 1 git.exe … "commit" "--" Aborting commit due to empty commit message. sh -c 'printf /nWITH-EDITOR:: $$: No such file or directory 2. I can neither pull nor push to my repo using ssh 128 git.exe … push -v gitlab refs/heads/main\:refs/heads/main Pushing to gitlab.com:aimebertrand/dotemacs.git fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. I understand that this is going on almost nothing, when meta info is concerned, so here there are: - Shell (customize-set-variable 'shell-file-name "C:/Windows/system32/bash.exe") (customize-set-variable 'sh-shell-file "C:/Windows/system32/bash.exe") (setenv "ESHELL" "bash") - I got git-bash installed and have my ssh-keypair in my user directory and for good mesures also in .ssh directory inside of my ````default-directory```` I am quite ambitious, but some intricacies go over my head aspecially when it comes to windows. Hope someone can point me in the right direction. Maybe with their own config or so. I do apologize if this question is not the best formed. But maybe with some of your input I can add needed Info.
eli-zaretskii · 2022-06-02 11:03
You are not telling enough. The commands you show are from the shell command prompt, but did you indeed invoke them from the Git Bash window? If so, why did you think that Emacs-related settings are relevant? And if you did invoke this from Emacs, please tell how you invoked that, and please also verify that the same commands do work from the Git Bash window (if they don't work from the Git Bash window, your problems are unrelated to Emacs, they are related to how you set up Git for Windows).
aimebertrand · 2022-06-02 11:28
Yeah, I was worried this would be the case. Now both errors are the results of me hitting $, when there is an error (for instance after "c c" to commit). I now realize that it is indeed a shell (bash in my case) stderr. However as I stated: Do not know where to got from there. I have parsed all of [https://emacs.stackexchange.com/search?q=magit+with-editor](https://emacs.stackexchange.com/search?q=magit+with-editor) for the first error to no end. Like I said. Maybe a pointing in a direction of a config that works might help. ​ ​ >If so, why did you think that Emacs-related settings are relevant? I can't say. But when I change `with-editor-emacsclient-executable` for instance I get different errors. P.S.: All works from git-bash like expected by the way.
FrozenOnPluto · 2022-06-02 12:34
Do the operations work from command line and from git bash? ie you can test from bottom layer to top - prove git works at all, by itself. Then when good, see if magit can work it. If you attack it from the top layer you’re never sure where problems are showing from.
aimebertrand · 2022-06-02 18:28
Hi there, Yeah gut works both with https and ssh.
redguardtoo · 2022-06-03 00:10
I'm not sure why you need set up `shell-file-name` and `sh-shell-file`. All you need to do is to make sure that `magit` can find the `git.exe` from `git-bash`. The easiest way is to set environment variable PATH. "Git Bash is an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience." So you set up git on Windows as on Linux/macOS. The git configuraiton is in the file `~/.gitconfig`. You ssh setup is in `~/.ssh`. Login into Git Bash, run command `cd ~ && pwd`, you can see what `~` is. It's helpful if you can double check if the cli Git does work inside Git Bash's shell. Read the book "Pro Git" if needed.
Phil-Hudson · 2022-06-03 14:10
1. Install cygwin, or 2. Install WSL2, or 3. Quit.
aimebertrand · 2022-06-03 14:35
You might be right. But there is a 4. Option: Fight to get a Mac or Linux machine 😁
jcs090218 · 2022-06-04 08:04
Yeah, I chose 3. Unfortunately, no chance to get good UX on Windows.
Phil-Hudson · 2022-06-04 08:35
Good for you!
jcs090218 · 2022-06-04 08:36
Yeah, I am happy with my choice! :)
aimebertrand · 2022-06-04 20:23
Option 2 with some sort of X forwarding seams to work Ok so far. Been trying it out since yesterday and I think I will stick with it and see how it goes. All the issues with magit are gone of course.