git with IntelliJ IDEA: Could not read from remote repository

前端 未结 30 2175
夕颜
夕颜 2020-12-07 08:11

Since a few weeks, I\'m not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem w

30条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 08:31

    I started getting Could not read from remote repository error recently when working with my github repository. My specs:

    • IntelliJ IDEA 2017.3.4 (Ultimate Edition)
    • Settings -> Version Control -> Git -> SSH executable -> Built-In
    • Fedora Linux

    Of course those problems occurred only when trying to push/pull/fetch etc. from IDE - executing same commands from command line worked like a charm.

    Solution that worked for me

    I didn't want to switch from Built-In SSH executable to Native, mostly because my native SSH client asks me for the password anytime I try to sync with remote repository.

    I solved this problem by switching from SSH remote URL to HTTPS URL. According to this GitHub help page - it is recommended to use HTTPS URL instead of SSH one.

    Changing remote URL from SSH to HTTPS

    In IntelliJ IDEA go to VCS -> Git -> Remotes..., select row containing "origin" and click on edit button. If you host your repository on GitHub, replace your SSH URL from:

    git@github.com:USERNAME/REPOSITORY.git
    

    to:

    https://github.com/USERNAME/REPOSITORY.git
    

    You can also get your HTTPS URL from your GitHub repository home page - click on "Clone or download" button and click on "Use HTTPS" link to display your repository's HTTPS URL:

    UPDATE 2018-03-13

    JetBrains just released IntelliJ IDEA 2017.3.5 that includes fix for SSH access to GitHub - https://blog.jetbrains.com/idea/2018/03/intellij-idea-2017-3-5-fix-for-ssh-access-to-github/

提交回复
热议问题