[Git] fatal: unable to access 錯誤訊息解法

  • 12061
  • 0
  • git
  • 2018-07-18

如提, 有時候執行Git的時候遇到proxy的錯誤.
會讓使用者無法操作.

grayyin@grayyin-VirtualBox:~/bitbucketTest$ git clone https://GRAYYIN@gitServer.com/testProject/test.git
Cloning into 'data_analysis'...
fatal: unable to access 'https://GRAYYIN@gitServer.com/testProject/test.git/': Received HTTP code 502 from proxy after CONNECT

有人抱怨用的好好的突然無法使用了,
但server其實是正常運作的. 我的經驗大概三種做法可以排除.

  1. 憑證過期.
    通常是使用者變更密碼或者某種原因, 造成憑證無效.
    https://stackoverflow.com/questions/11693074/git-credential-cache-is-not-a-git-command
    可以參考這篇
    $ git config --global credential.helper grayyin
    修改後經過https clone就可以了.
  2. proxy異常.
    參考:
    https://confluence.atlassian.com/stashkb/can-t-clone-or-pull-due-to-a-git-outbound-proxy-604537638.html
    # Linux
    export http_proxy=http://{Your Proxy URL}:{Port}
    export https_proxy=http://{Your Proxy URL}:{Port}
    export no_proxy=****
    
    # Windows
    set http_proxy http://{Your Proxy URL}:{Port}
    set https_proxy http://{Your Proxy URL}:{Port}
    export no_proxy=****
  3. 簽SSH Key吧.
    可以參考Bitbucket的文章.
    https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
    Github文件
    http://github.com/guides/providing-your-ssh-key
    或者Git的文件
    https://git-scm.com/book/zh-tw/v1/%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E7%94%9F%E6%88%90-SSH-%E5%85%AC%E9%96%8B%E9%87%91%E9%91%B0

    先建出Key 然後再傳給管理員簽.

    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/schacon/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /Users/schacon/.ssh/id_rsa.
    Your public key has been saved in /Users/schacon/.ssh/id_rsa.pub.
    The key fingerprint is:
    43:c5:5b:5f:b1:f1:50:43:ad:20:a6:92:6a:1f:9a:3a schacon@agadorlaptop.local
    
    $ cat ~/.ssh/id_rsa.pub
    ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
    GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
    Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
    t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En
    mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx
    NrRFi9wrf+M7Q== schacon@agadorlaptop.local


     

通常這樣就可以排除這個問題了.