git produces Gtk-WARNING: cannot open display

John Manak picture John Manak · Apr 18, 2013 · Viewed 77.6k times · Source

I've been working on my project remotely through the command line on a machine to which I don't have admin rights and after running git push origin master I get the following error message:

(gnome-ssh-askpass:29241): Gtk-WARNING **: cannot open display:

My .git/config file has the following contents:

    [core]
       repositoryformatversion = 0
       filemode = true
       bare = false
       logallrefupdates = true 
    [remote "origin"]
       fetch = +refs/heads/*:refs/remotes/origin/*
       url = https://[email protected]/username/repository.git 
    [branch "master"]
       remote = origin
       merge = refs/heads/master

I was getting the 403 error earlier. Following the comment here, I put my username before the @ sign in the remote url and since then, I've been getting the Gtk error.

When I login to the machine using ssh -X and try to push, I get the following error:

X11 connection rejected because of wrong authentication.
(gnome-ssh-askpass:31922): Gtk-WARNING **: cannot open display:localhost:10.0

If I change the url of the remote to [email protected]:username/repository.git, then the error is:

ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

Do you know how to fix this?

Answer

John Manak picture John Manak · Apr 19, 2013

I have finally discovered a solution to the problem. As it was described here, I ran the following command in the terminal:

  unset SSH_ASKPASS

and then running git push origin master works the way it should. You can also add the line to your .bashrc file.