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
相关推荐
我命由我1234512 小时前
Git 推送报错:error: src refspec main does not match any
运维·git·gitee·github·运维开发·学习方法·版本控制
阿里嘎多学长13 小时前
2026-09-20 GitHub 热点项目精选
开发语言·程序员·github·代码托管
峰向AI13 小时前
skill-up: [阿里开源] 让 AI Agent Skills 自己进化的评估工具
github
子林super17 小时前
顺序表用Python3定义与增删改查
github
子林super17 小时前
Python非空判断与类型检查写法
github
子林super17 小时前
Python list与array关键区别及使用场景
github
子林super17 小时前
Python中None与null的区别
github
u13013019 小时前
GitHub 热榜项目:周榜(2026-09-20)
人工智能·github
u13013021 小时前
GitHub 热榜项目:日榜(2026-09-20)
人工智能·github
逛逛GitHub21 小时前
外网 3500 万人围观的 Jev 模型,有这 10 个神奇玩法。
github