git简单使用

git使用


创建一个GitHub项目

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NuIQqmDp-1665159170242)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007222759508.png)]
给项目取个名字
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QR3d5FgH-1665159170243)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007223006400.png)]
创建成功后页面
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cekF2Pm1-1665159170243)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007223146726.png)]

使用git上传项目到github

在本地机器上进入要上传项目的文件目录,右键->Git Bash Here
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GlpfR4N1-1665159170244)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007235304321.png)]

git init #初始化Git仓库,将此文件夹作为git仓库
git add .  #将项目上所有的文件添加到仓库中
git commit -m “first commit  #表示你对这次提交的注释
git remote add origin https://自己的仓库url地址	#将本地的仓库关联到github上
git push -u origin master  #把代码上传到github仓库

git常见命令与问题

本地仓库重新设置源

git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit
git remote remove origin # 删掉原来git源
git remote add origin [YOUR NEW .GIT URL] # 将新源地址写入本地版本库配置文件
git push -u origin master # 提交所有代码

解决 fatal: unable to access ‘https://github.com/…/.git’: Could not resolve host: github.com

#取消代理设置
git config --global --unset http.proxy 
git config --global --unset https.proxy

有时候是因为网络被墙的原因,网速慢,重试几次就成功

本文参考:

git常用命令
在github上上传本地项目步骤(两种方式)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浩茫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值