git 常见问题的解决方案

前言

  • 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.
    原文作者:kunnan
    原文地址: https://segmentfault.com/a/1190000012232288
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞