github使用记录

1. 首次上传本地项目到 GitHub

1.1 准备 GitHub 仓库

复制代码
登录 GitHub,点击右上角 + → New repository

输入仓库名称(建议与本地目录同名)

选择公开(Public)或私有(Private)

不要勾选 "Initialize this repository with a README"

点击创建

1.2 初始化本地仓库

复制代码
# 进入项目目录
cd /path/to/your/project

# 初始化Git仓库
git init

# 添加所有文件到暂存区
git add .

# 提交更改(添加注释)
git commit -m "Initial commit"

1.3 添加远程仓库

复制代码
# 添加远程仓库(替换username和reponame)
git remote add origin https://github.com/<username>/<reponame>.git

1.4 添加令牌访问远程仓库

复制代码
git remote set-url origin https://<token>@github.com/<username>/<reponame>.git

## token:创建好的令牌号
## 参考: https://blog.csdn.net/weixin_44415582/article/details/131503585

1.5 推送代码

复制代码
# 首次推送需要指定上游分支
git push -u origin main

如果push不上,可以添加代理端口:
参考:https://blog.csdn.net/weixin_43914200/article/details/121316043
相关推荐
草梅友仁1 小时前
RSS Zero 项目预告 | 2025 年第 24 周草梅周报
开源·github·rss
粥里有勺糖5 小时前
视野修炼第123期 | 你在用Node几?
前端·javascript·github
小华同学ai6 小时前
6.2k tar 热门项目,揭秘:一篇 Markdown 如何秒生成 PPT、书籍、文章
前端·后端·github
Jooolin8 小时前
Git 与 GitHub 的最佳协作范式:从 Fork 到 Pull Request,打开开源贡献之门
git·github·ai编程
Jooolin8 小时前
【编程史】Git是啥?它和GitHub关系是?
linux·git·github
南囝coding9 小时前
这个 361K Star 的项目,一定要收藏!
前端·后端·github
隔壁小白14 小时前
Laravel模板Blade 用法 x-layouts.guest 和x-guest-layout 什么区别
github·laravel
创实信息16 小时前
软件开发 | 从 Azure DevOps迁移至GitHub企业版的最佳路径
ai·github·azure·devops
qianmoQ17 小时前
GitHub 趋势日报 (2025年06月12日)
github
waterHBO1 天前
( github actions + workflow 03 ) 手动添加 token, 防止权限不够
github