git使用
创建一个GitHub项目
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NuIQqmDp-1665159170242)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007222759508.png)]](https://i-blog.csdnimg.cn/blog_migrate/7b619d5c1f580c5d905e62b48ca361fc.png)
给项目取个名字
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QR3d5FgH-1665159170243)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007223006400.png)]](https://i-blog.csdnimg.cn/blog_migrate/4ccd0935ae28e07cbd52d9699bf5292e.png)
创建成功后页面
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cekF2Pm1-1665159170243)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007223146726.png)]](https://i-blog.csdnimg.cn/blog_migrate/184987cd130b0919df2756dfb77b6151.png)
使用git上传项目到github
在本地机器上进入要上传项目的文件目录,右键->Git Bash Here
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GlpfR4N1-1665159170244)(C:\Users\tgy18\AppData\Roaming\Typora\typora-user-images\image-20221007235304321.png)]](https://i-blog.csdnimg.cn/blog_migrate/6c205782fbb338b0636c13a7234523fb.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
有时候是因为网络被墙的原因,网速慢,重试几次就成功
本文参考:

被折叠的 条评论
为什么被折叠?



