linux 使用 git The requested URL returned error: 403

本文详细介绍了如何通过命令行方式在GitHub上创建并推送项目的过程,包括初始化仓库、添加文件、配置用户信息等关键步骤,并解决了常见错误403的问题。

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

从github上给出的git使用说明上看,流程是这样的:

…or create a new repository on the command line

echo "# Stormcv-web" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Applepleple/Stormcv-web.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/Applepleple/Stormcv-web.git
git push -u origin master

但是发现在使用push时会出现 The requested URL returned error 403,发现以下命令解决问题

git remote set-url origin https://【Your Account】@github.com/Applepleple/Stormcv-web.git

除了上述步骤外,还需要设置自己的账户名和密码

git config --global user.name "Your Name Here"
git config --global user.email "your_email@example.com"


如果需要使用ignore的话,可以在主目录下建一个.gitignore的文件,具体的书写格式这里不再详细介绍啦

添加.gitignore后,用git add \*就可以添加非ignore文件了

如果ignore的文件已经被commit过了,需要

git rm -r –cached .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值