git 常见问题的解决方案

本文介绍了解决Git中因本地分支与远程分支未建立联系导致无法拉取的问题,提供了设置跟踪信息的方法,并探讨了SSL证书验证问题及解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

  • 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值