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
相关推荐
CoderJia程序员甲41 分钟前
GitHub 热榜项目 - 日榜(2026-01-28)
人工智能·ai·大模型·github·ai教程
极智-9964 小时前
GitHub 热榜项目-日榜精选(2026-01-28)|实用资源与工具、开源LLM应用 | pi-mono、supermemory、mlx-audio等
开源·github·语音处理·密钥管理·llm应用·iptv资源
Lust Dusk4 小时前
如何通过GitHub找到一个人?
安全·网络安全·github
ONLYOFFICE4 小时前
ONLYOFFICE 桌面编辑器正式成为 ShaniOS 默认办公套件
linux·编辑器·github·onlyoffice
独自破碎E4 小时前
如何把本地文件夹和已存在的 GitHub 远程仓库同步
github
嘿吖嘿嘿~4 小时前
怎么解决git@github.com出现Permission denied (publickey)的问题
git·github
独自破碎E4 小时前
CRLF与LF的行分隔符警告⚠️
github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2026-01-27)
github
无限进步_1 天前
206. 反转链表 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio
无限进步_1 天前
203. 移除链表元素 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio