利用git在github上传代码

本文前提是已经安装了git

1.登录github,创建一个仓库
在这里插入图片描述2. 点击右侧code,复制git地址
在这里插入图片描述

3.在本地以路径下,右击选择***“git bash here”***
在打开的控制台输入

git clone https://github.com/***/test.git
  1. 将需要上传的代码放在上一步生成的test文件夹内
  2. 初始化
git init

在这里插入图片描述6. 添加远程仓库地址:git remote add origin (address)

git remote add origin https://github.com/***/test.git

在这里插入图片描述如果在这一步出现错误:

error: remote origin already exists.

则执行

1、先输入git remote rm origin 删除关联的origin的远程库
2、关联自己的仓库 git remote add origin https://github.com/***/test.git
3、最后git push origin master(或许是git push origin main,主要取决于自己创建的仓库分支名,可通过`git branch -l`查看分支名),这样就推送到自己的仓库了。
  1. 添加代码(. 表示添加所有代码)
git add .
  1. 添加这次提交的备注信息
git commit -m "备注信息"
  1. 提交到远程仓库
git push origin master (git push origin main)

在这里插入图片描述

过程中要登陆github账户,关联github账户到git

这一步如果出现连接错误,大概率是梯子原因。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值