10

I'm using GNU Emacs on Windows, and I am unable to use magit-push to push my local changes to a remote repository. This happens with remote repositories regardless of if they are accessed with SSH or HTTPS. What do I need to do to make magit-push work on Windows as seamlessly (or at least nearly so) as it does on my Linux machines?

All I see in the *Messages* buffer is

Running c:/Program Files (x86)/Git/bin/git.exe push -v origin master:refs/heads/master

The same shows in the *magit-process* buffer, more or less. Nothing more useful. I am able to git push from the command line, but it does ask for my ssh key's password. Might that be the problem? I've tried loading the key with Pageant (PuTTY's key agent), but that didn't seem to make a difference.

If it's helpful, I have Cygwin installed, and would be happy with a solution that involved forcing Emacs to use Cygwin's executables.

6

Magit's wiki now features a page about the various ways one can push from Magit when using MS Windows. Also checkout the new ssh-agency package. Both the wiki page and the package were written by @npostavs.

Also note that it is virtually never Magit's fault if you cannot push. It's usually a configuration issue (even if you can push from the shell but not when using Magit).

6

Usually, the problem is that Emacs can't access the password prompt of git on Windows. Thus, it seems to "hang" on push, where it really is waiting for your password. You can circumvent this by using an ssh key instead of a username/password in your git repo, and doing the first push manually in the shell (git will remember your ssh password after the first push).

  • 1
    The Git bash shell doesn't seem to be remembering my ssh password, so more pushes are just seeing the same thing. – Ryan Sep 30 '14 at 23:17
3

If you haven't already done so, I would recommend using SSH instead of HTTP as many have recommended to me during my investigation of this. That said, I was able to resolve this issue using the below FAQ:

https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-with-ssh-passphrase

The missing component (from Github's Git Bash .bashrc script) is that it doesn't handle ssh-agent startup for interfaces such as the Windows command line or emacs. Following the above steps initiates ssh-agent upon emacs startup. Note, you will have to start Git Bash and enter your SSH passphrase upon starting/restarting your machine.

2

I too have experienced this behavior for a while, and until today haven't gotten around to really trying to fix it. I did so by placed the following in my init-file:

(setenv "GIT_SSH" "C:/Path/to/PuTTY/plink.exe")

I also tested this by opening up a clean Emacs (emacs -Q), loading magit, and evaluating that line, and it worked.

This works with Pageant, so there is no need to mess with ssh-agent.

  • 1
    For me this was the best solution for someone who's installed command-line git and the PuTTY-related executables like pageant. – Tom Purl Oct 3 '18 at 14:40
1

If you already have Cygwin installed you can use keychain and keychain-environment to manage your keys.

Use the shell of your choice to launch keychain, then

(require 'keychain-environment)
(keychain-refresh-environment)

to ensure the keys are loaded into Emacs.

  • Hmmm. I tried this, and nothing really changed. The magit-push command hung just like it always does. – Ryan Oct 27 '14 at 21:24
1

I never figured out how to fix this with just MSYS Git and Emacs, but here's seamless workaround.

Add Git Credential Winstore to your $PATH. Git-Credential-Winstore will use the Windows keychain to manage your passwords for you and Magit will happily push to remote repositories.

In your .gitconfig file, set the following:

[credential]
        helper = "winstore"

This works because the Git Credential Docs state that "if the helper name is not an absolute path, then the string git credential- is prepended." I prefer this approach.

Alternately, you can simply run git-credential-winstore.exe and it will install itself to your AppData folder and fill in your .gitconfig file with a hardcoded path to it's location. After running it, your .gitconfig will look like this:

[credential]
        helper = !"c:\\Users\Joe\\\AppData\\Roaming\\GitCredStore\\git-credential-winstore.exe"

The exclamation point instructs Git to treat the string as an absolute path.

0

As @bastibe pointed, Magit is probably waiting for a password input and just hangs in there...

I recall the following working when I was forced to used Windows :-). I don't recall the exact command name, also make sure that the exec-path contains c:/Program Files (x86)/Git/bin/.

(setenv "GIT_ASKPASS" "git-gui--askpass")
0

I ran runemacs.exe from the git shell. Now the git push from magit works.

  • 1
    This doesn't seem to relate to the question in any way. If you meant to answer the question, please edit your answer that explains how running runemacs is somehow related to magit. – Gilles Mar 14 '15 at 12:07
  • nice. i get marked for deletion before i even get a chance to better explain? it's an answer (solution) to the problem. – Majid alDosari Mar 14 '15 at 17:10
  • 1
    I don't think the answer deserves to be downvoted. But it may be better to explain the reason why it worked (if running from Git shell on windows, some environment variables will be initialized differently in Emacs, this will also cause Magit to be able to interact with Git in the way it understands). Perhaps the way OP tried to run Magit commands interacted with Git in a way Magit didn't expect. – wvxvw Mar 14 '15 at 18:12
  • 1
    This is an answer. The user might not know why it made a difference, but they are saying what worked in their case. – Malabarba Mar 14 '15 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.