git 常見問題的解決方案

kunnan發表於2017-11-30

前言

  • fatal: unable to access
    `https://github.com/zhangkn/cy…`: SSL certificate
    problem: unable to get local issuer certificate
  • There is no tracking information for the current branch.

There is no tracking information for the current branch.

今天git pull發現了 以下問題

There is no tracking information for the current branch.
Please specify which branch you want to merge with.

因為本地分支和遠端分支沒有建立聯絡 (使用git branch -vv 可以檢視本地分支和遠端分支的關聯關係) .

See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> develop

devzkndeMacBook-Pro:guangyouqian devzkn$ git branch -vv 
* develop b7e5c40 Merge remote-tracking branch `origin/develop` into develop
  master  5128d9e [origin/master] Merge branch `develop`

根據命令列提示只需要執行以下命令即可
git branch –set-upstream-to=origin/遠端分支的名字 本地分支的名字

See git-pull(1) for details.

devzkndeMacBook-Pro:guangyouqian devzkn$ git pull origin develop
From gitlab.v6h5.cn:guangyouqian/guangyouqian
 * branch            develop    -> FETCH_HEAD
Updating b7e5c40..798cbc5
Checking out files: 100% (329/329), done.
Fast-forward

-p 選項展開顯示每次提交的內容差異,用 -2 則僅顯示最近的兩次更新:

devzkndeMacBook-Pro:guangyouqian devzkn$ git log -p -2

解決方案

指定當前工作目錄工作分支,跟遠端的倉庫,分支之間的連結關係。

在此之前,我們必須要指定想要push或者pull的遠端分支。

devzkndeMacBook-Pro:guangyouqian devzkn$ git pull origin develop
devzkndeMacBook-Pro:guangyouqian devzkn$ git branch --set-upstream-to=origin/develop develop
Branch develop set up to track remote branch develop from origin.

fatal: unable to access `https://github.com/zhangkn/cy…`: SSL certificate problem: unable to get local issuer certificate

  • To disable TLS/SSL verification for a single git command

try passing -c to git with the proper config variable, or use Flow`s answer:

git -c http.sslVerify=false clone https://example.com/path/to/git
To disable SSL verification for a specific repository

示例:

iPhone:~ root#  git -c http.sslVerify=false clone https://github.com/zhangkn/cycript-utils.git /usr/lib/cycript0.9/com/tyilo
Cloning into `/usr/lib/cycript0.9/com/tyilo`...
remote: Counting objects: 46, done.
remote: Total 46 (delta 0), reused 0 (delta 0), pack-reused 46
Unpacking objects: 100% (46/46), done.
Checking connectivity... done.
  • Disabling TLS(/SSL) certificate verification globally is a terribly
    insecure practice. Don`t do it. Do not issue the above command with a
    –global modifier.

If the repository is completely under your control, you can try:

`git config http.sslVerify false
`

  • There are quite a few SSL configuration options in git. From the man
    page of git config:



http.sslVerify
    Whether to verify the SSL certificate when fetching or pushing over HTTPS.
    Can be overridden by the GIT_SSL_NO_VERIFY environment variable.

http.sslCAInfo
    File containing the certificates to verify the peer with when fetching or pushing
    over HTTPS. Can be overridden by the GIT_SSL_CAINFO environment variable.

http.sslCAPath
    Path containing files with the CA certificates to verify the peer with when
    fetching or pushing over HTTPS.
    Can be overridden by the GIT_SSL_CAPATH environment variable.
A few other useful SSL configuration options:

http.sslCert
    File containing the SSL certificate when fetching or pushing over HTTPS.
    Can be overridden by the GIT_SSL_CERT environment variable.

http.sslKey
    File containing the SSL private key when fetching or pushing over HTTPS.
    Can be overridden by the GIT_SSL_KEY environment variable.

http.sslCertPasswordProtected
    Enable git`s password prompt for the SSL certificate. Otherwise OpenSSL will
    prompt the user, possibly many times, if the certificate or private key is encrypted.
    Can be overridden by the GIT_SSL_CERT_PASSWORD_PROTECTED environment variable.

相關文章