使用git上传github仓库

文章目录

使用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!!!

相关推荐
m0_694845576 小时前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp
June`6 小时前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
春日见6 小时前
如何创建一个PR
运维·开发语言·windows·git·docker·容器
weixin_6688 小时前
GitHub 2026年AI项目详细数据汇总表-AI分析-分享
人工智能·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
stevenzqzq1 天前
git 常用操作
大数据·git
weixin_6681 天前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
Curvatureflight1 天前
Git工作流最佳实践:从混乱到优雅
git
MicrosoftReactor1 天前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~9701 天前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github