7

I was developing code on Ubuntu using VMware. Everything was fine, I was coding and committing it to my Github account without any problem. BUT suddenly it stopped working, it would say: fatal: unable to access 'https://github.com/hm0ss/nst.git/': Could not resolve host: github.com

What Have I done? I searched it on google and used config command and other advice, with no avail. I also made another git repository, but that failed either. I switched to GitLab and made a repository there, which had no benefit: "Unable to access 'https://gitlab.com/hma.globe/nst2.git/': Could not resolve host: gitlab.com" I need to say that I was using a proxy (socks indeed) but even disconnecting socks server (or removing proxies from google chrome) did not work either. By the way, I even switched to windows and tried to commit but came across to same error. After trying some 2 hours, I'm now in big trouble.

m0ss
  • 334
  • 2
  • 4
  • 17

3 Answers3

9

I had issues like this and there is no one specific set of instructions to resolve this . however i tried running this command and it worked for me

git config --global --unset http.proxy
Then run

git remote  set-url origin <repository link>

After commiting your new changes try running
this command if regular push gives you an error

git push origin <branch>  --force
iceweasel
  • 756
  • 1
  • 6
  • 11
1

Check first if the issue persists.

GitHub status has been reporting several issues recently (in the last few hours) which could explain "sudden" problems of yours.

For example: this incident: "We are investigating degradations to GitHub.com".

GitLab had no recent issues though, which means a network issue on your side could also be a factor.

The OP did a reset of the VMware to solve the network issue.
And a full reset to origin/master + copy of the current work to lake and push a new commit successfully to GitHub.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hey, thanks for your reply. About your point on my network problem, I am able to surf the internet quite normally, even I'm able to open Github or Gitlab. I also used two commands which other people told to resolve proxy issue (if present) : git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 git config --global --unset http.proxy git config --global --unset https.proxy But nothing has worked. After 3 hours of trying, I think I'll upload them manually on GitHub website. But this is quite weird :| – m0ss Apr 22 '20 at 05:25
  • 1
    @m0ss I was thinking to a local Git config issue indeed. Note that removing http.proxy config would still leave an environment variable like `HTTP_PROXY` active (if you have one set) and used by Git. – VonC Apr 22 '20 at 05:32
  • Yes, I saw some threads mentioning this, but unfortunately, I don't have any ideas about how to fix them. All I say about HTTP_PROXY was some commands which I did not know how to use them and even where to enter them? I have removed my .git folder many times and initialized it again but didn't work. I have been using proxies and VPNs for a long time but had not ever had this issue. But recently, I came across it before this time, which was resolved spontaneously. I'd be appreciated if you explain more how to solve that HTTP_PROXY issue. – m0ss Apr 22 '20 at 05:39
  • 1
    @m0ss First, type `env|grep -i proxy` to check if you had any proxy-related environment variable set. – VonC Apr 22 '20 at 05:45
  • I did. It came out: ADSK_CLM_WPAD_PROXY_CHECK=FALSE – m0ss Apr 22 '20 at 07:56
  • By the way, I deleted git several times and tried to re init it and post again. after git init, I also set my remote using git remote add ..... but when I try to push, it says: fatal: 'github/hm0ss/nst' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists I don't really know why it keeps annoying me :|| – m0ss Apr 22 '20 at 07:59
  • I should also say now that I check VMware, I see it's not even connected to the internet! That's really strange because at the same time I'm browsing sites on windows – m0ss Apr 22 '20 at 09:23
  • 1
    @m0ss Strange indeed. What are the network settings in your browser? Especially regarding DNS: it must contact one to be able to resolve the URLs. – VonC Apr 22 '20 at 10:23
  • Using ipconfig, it came out to be 192.168.1.1 I tried it on windows by the way. – m0ss Apr 22 '20 at 18:23
  • 1
    @m0ss That looks about right. Maybe some of the suggestions in https://superuser.com/a/1127602/141 could help? – VonC Apr 22 '20 at 18:39
  • Thanks, By the say that although I have the internet on my windows and can surf quite normally, git still does not work on windows! That is, I copy the repository from my VMware to my windows desktop and use git bash to push that, but it say: fatal: 'github/hm0ss/nst' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. – m0ss Apr 22 '20 at 19:15
  • 1
    @m0ss Can you activate TRACE2 as in https://stackoverflow.com/a/61307754/6309? You might have more clues that way. – VonC Apr 22 '20 at 19:25
  • I coppy pasted GIT_TRACE2_EVENT=1 GIT_TRACE2_PERF=1 git status in my git bash. The result was too long to be printed hear, but after a lot of stuff, it said: On branch master nothing to commit, working tree clean – m0ss Apr 23 '20 at 04:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/212317/discussion-between-vonc-and-m0ss). – VonC Apr 23 '20 at 05:04
0

For your additional information just in case you find this post. there are two scenario why it was happen First you enable your proxy so git --unset http.proxy

second you network using proxy so configure your proxy. which i found this useful answer

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 28 '22 at 17:12