文章目录
使用git上传github仓库
1 安装和设置 Git
Git官网,直接下载安装Git即可。在本地需要上传的代码文件夹中右击Open Git Bash here。
2 安装好 Git 之后,在命令行中输入以下命令来设置你的 GitHub 用户名和电子邮件
python
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
git config -l ###检查是否设置成功
3.在本地初始化你的项目
python
git init

初始化后可以在文件夹中看到.git文件,如果没有发现就是没有打开隐藏文件。
4.添加文件到你的 Git 仓库
将该文件夹中所有文件添加到仓库
python
git add *

5.提交
使用以下命令来提交:
python
git commit -m "first commit"

6 修改分支名字并连接 GitHub 仓库
这里注意要选择HTTP,如果没有设置公钥的话。
可以看出分支名字和自己新建仓库不一样,这里是master,仓库里是main
所有改成main
python
git branch -m master main

连接仓库并推送
python
git remote add origin https://github.com/LittleBeanBun/CUDA.git
git push -u orgin main
最后登录一下git刷新一下页面即可。
如果中途遇到问题,显示分支已存在,可以使用一下命令移除之后再进行添加。
python
git remote remove origin

小结
有个视频讲解的很清楚,推荐查看。视频链接:手把手教你把自己的项目利用git上传到GitHub!!!