6

I'm working on a school project via an IDE that is new for me: IntellIJ.

In order to submit my project (via git) I created a Git repository, added the correct remote with its password and tried to push my work on the master branch (after adding / committing said work with success).

At first I received the following error message:

Push failed: Failed with error: fatal: Could not read from remote repository.

I then went into my settings and set my SSH executable to Native to try and solve this problem. But it did not work, and I can't seem to push my project on this remote even though the password I inputed was correct.

Here is my .git/config file:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@git.epitech.eu:/kade_c/Java_jcoinche_2016
    fetch = +refs/heads/*:refs/remotes/origin/*

Where did I go wrong?

  • May I ask you to try to connect to the repository from the Git Bash? This would rule out IntelliJ itself as being a problem. – Tim Biegeleisen Nov 09 '16 at 09:30
  • As in clone it in command line? This does not work, I get the same error. –  Nov 09 '16 at 09:33
  • Then this sounds like a settings problem with your credentials. – Tim Biegeleisen Nov 09 '16 at 09:35
  • Which Git host are you using (e.g. GitHub, Bitbucket, etc.) ? – Tim Biegeleisen Nov 09 '16 at 09:38
  • Wouldn't it tell me if I inputed the wrong password when I was prompted to? –  Nov 09 '16 at 09:38
  • I'm not sure of that, any way to figure it out? –  Nov 09 '16 at 09:39
  • Please show us the actual URL. Yes, the cannot read from repo error could be a manifestation of a wrong password. – Tim Biegeleisen Nov 09 '16 at 09:42
  • I have added the URL. Would there be a way to change the password I previously inputed? The research I have done was not conclusive –  Nov 09 '16 at 09:43
  • I don't know anything about your host, but, for example, in the case of Bitbucket, someone needs to tell Bitbucket what your public key is, so it knows that it can trust you. In other words, there may be another configuration step beyond just setting your local password. – Tim Biegeleisen Nov 09 '16 at 09:48
  • If you have a link to any instructions for using your Git repository, then please post that as well. – Tim Biegeleisen Nov 09 '16 at 10:00
  • After using this intellij install for a year and a half this suddenly started doing this to me. @sagarsys solution of switching to native fixed it for me. – marathon Feb 23 '18 at 08:18

3 Answers3

14

Go to Settings > Version Control > Git. Make sure SSH executable is set to “Native.” (If it's already so, switch it to “Built-in,” apply it, and then again switch back to “Native.”).

If it still doesn't work, and you have the GitLab plugin installed. Try deactivating it and restarting the IDE. Issue reported here: https://youtrack.jetbrains.com/issue/TW-47704

sagarsys
  • 331
  • 2
  • 9
5

I ran into this same problem, using a private github repo; what I did was change the remote url from
url = git@github.com:/username/repository.git
to
url = https://github.com/username/repository.git.

Both are valid remote URLs, one for HTTPs, and for SSH, but it's possible that a third-party program changed from one to your other in your config file. That happened to me, worth a try.

In my case, when I changed it, it worked, because I wasn't set up to use it over SSH, which typically requires extra configuration, so usually the HTTPS version is default unless one does the extra setup.

So, in your case, perhaps change that line to
url = https://git.epitech.eu/kade_c/Java_jcoinche_2016?

Max Langhof
  • 23,383
  • 5
  • 39
  • 72
Aaron Wallentine
  • 2,318
  • 24
  • 22
2

From my experience this seems to be most often caused by SSH Keys with a passphrase, JetBrains IDEs have no mechanism to prompt for the passphrase and therefore fail to authenticate properly. The only solutions I have found that resolve this issue are to either use a key without a passphrase or use to HTTPS remotes.

Note: Another issue you might face is with hashed known_hosts compatibility with Intellij. See this answer to fix it: https://stackoverflow.com/a/28294279/1311745

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66