Home > Net >  git fetch, git pull not working in my VM in GCP
git fetch, git pull not working in my VM in GCP

Time:07-13

I am a GCP user. I have a VM that is running in GCP.

But recently, when I try to run the "git pull" or "git fetch" commands to update my project, it just hung there, and there are no responses.

My project is on GitHub.
It worked very well a few weeks ago. I didn't change any ssh or network config.

Not sure what kind of problem it is. I will appreciate it if anyone could give some advice.

CodePudding user response:

I found the problem and resolved it. Hope this can help other people who faced the same issue as mine.

This was my ssh config file

Host github.com
      HostName github.com
      PreferredAuthentications publickey
      IdentityFile ~/.ssh/id_rsa
      AddKeysToAgent yes

After I removed the line AddKeysToAgent yes, it works now. I don't know why it worked before.

CodePudding user response:

First, you need to make sure if you are indeed using ssh on GCP in your repository folder:

cd /path/to/repository
git remote -v
# Check the URL is
# [email protected]:you/yourRepository
#              ^^^ (note the :)
# Or:
# ssh://[email protected]/you/yourRepository
#                    ^^^ (note the /)

Check also your environment variables:

env|grep -i SSH

(A GIT_SSH... environment variable might affect how Git operates with SSH)

And see if the network route is still opened from your GCP shell to GitHub:

curl -v telnet://github.com:22
# You should see
Connected to github.com (140.82.121.3) port 22 (#0)

For testing, check if you can use (while entering your GitHub account and a GitHub Personal Acccess Token or PAT) use HTTPS:

git ls-remote https://github.com/You/yourRepository

If you are using SSH, activate traces on SSH ,and on Git itself with TRACE2:

export GIT_SSH_COMMAND='ssh -Tv'
GIT_TRACE2_EVENT=1 git pull
# or
GIT_TRACE2=1 git pull

As noted in the OP Louis Hong's answer, activating the traces would show the step where, by tring to add a key to an ssh-agent (from the ~/.ssh/config), said ssh-agent might request a passphrase for another (encrypted) key, thereby hanging on stdin.

  • Related