For some repositories at work I get the following message when I try to push my commits:

GitError! Could not read from remote repository.  [Type `$' for details]

The details read:

128 C:/Program Files/Git/mingw64/libexec/git-core/git.exe … "push" "-v" "origin" "master:refs/heads/master"
Pushing to ssh://git@XXX.git

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Any idea what the problem could be? Running the above git command from a git-bash (minus those tripple-dots) also works. In fact, that's my workaround. Compose the commit with magit and just type git push in a git-bash. Pushing to github.com repository on the same machine works from magit.

  • Type TAB on the 128... line to actually see the details. – tarsius Nov 29 '17 at 10:26
  • Thanks, I edited the question accordingly. I'm mainly puzzled by the fact that git-bash doesn't give me such an error. – B_old Nov 29 '17 at 10:37
  • Have you read this? github.com/magit/magit/wiki/Pushing-with-Magit-from-Windows – npostavs Nov 29 '17 at 11:16
  • 2
    Since you are pushing to ssh://..., you must be using SSH keys to authenticate against the repository. I'd start by making sure that git-bash expands $HOME to the same directory as M-x getenv HOME. Or, perhaps, you are running an ssh-agent program that manages the keys for you, but it runs in the git-bash session, and not in Emacs (so you would need to start ssh-agent in Emacs too). – wvxvw Nov 29 '17 at 11:36
  • @wvxvw: That was the perfect hint! Emacs and git-bash were seeing different HOME variables. The easiest way was creating a symlink to .ssh so that emacs sees it. Problem solved. Thanks. – B_old Nov 29 '17 at 13:17

The problem was that emacs was seeing a different $HOME variable than git-bash and could therefore not find the ssh-keys. Thanks to @wvxvw for pointing me in the right direction. After creating a symlink everything works now.


I had the same error message until moments ago. I had to install the package ssh-agency. A solution that is also documented in the link provided by @npostavs

In spacemacs you do that by adding it to dotspacemacs-additional-packages.

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.