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

相关推荐
用户2991422196805 小时前
GitHub 热榜项目:周榜(2026-11-08)
人工智能·开源·github
用户2991422196805 小时前
GitHub 热榜项目:日榜(2026-11-08)
人工智能·开源·github
miofly7 小时前
GitHub 周榜趋势速报 | 2026-11-08
开源·github
miofly8 小时前
GitHub 日榜趋势速报 | 2026-11-08
开源·github
miofly1 天前
百度开源ERNIE 5.5 Flash Base,总参数280B仅激活14B
开源·github
dong_junshuai1 天前
每天一个开源项目#154 Nushell:结构化管道怎样跨过文本边界
github
高调的涵涵1 天前
删了1.2GB,.git仍是1.2GB
git
Jason_gao9991 天前
Github Copilot 新手极速上手指南
人工智能·github·copilot
GitHub实测笔记1 天前
hexyl 本机实测:8MiB 转储中位 102ms、od 696ms(约 6.8×);默认双面板,NO_COLOR 下要 --color=force
github
MoRay1 天前
放弃云端 Computer Use,我用 Python 手搓了一个带“物理防呆”的本地 GUI Agent 底座
python·github