Fix git 提交代码错误

本文介绍了如何解决使用Git时遇到的HTTPS 403 Forbidden错误,通过将远程仓库地址从HTTPS改为SSH的方式进行解决。同时,针对没有分支跟踪信息的问题,提供了设置分支上游的方法。

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

今天用git clone下代码,修改,push提交,发现以下错误

[root@localhost gocache]# git push origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/zebozhuang/gocache.git/info/refs

查一下,原来是我用https clone代码,在.git下的remote url也会使用https,参考

http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

在.git下修改config

    url = ssh://git@github.com/zebozhuang/gocache.git

 即可。

问题的实质是git的版本过低导致。参考

https://help.github.com/articles/https-cloning-errors/

问题解决!

----------------------------------------------Fri Apr 10 22:45:01 CST 201,出现新问题

git pull

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch y

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

也属于老版本问题,解决

git branch --set-upstream-to=origin/master master

参考

http://stackoverflow.com/questions/10147475/git-checkout-tag-git-pull-fails-in-branch

 

转载于:https://www.cnblogs.com/zhuangzebo/p/4415808.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值