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
相关推荐
你不是我我10 小时前
【Java 开发日记】我们来说一说 Redis 主从复制的原理及作用
java·redis·github
-拟墨画扇-13 小时前
Git | 分支管理操作
git·gitee·github·gitcode
无限进步_19 小时前
C++ Vector 全解析:从使用到深入理解
开发语言·c++·ide·windows·git·github·visual studio
顾安r20 小时前
12.27 脚本网页 GITHUB推送教程
linux·css·html·gitlab·github
A132470531220 小时前
curl命令入门:命令行测试接口
linux·运维·服务器·网络·编辑器·github·vim
AC赳赳老秦20 小时前
企业级人工智能平台选型深度分析:天翼云 DeepSeek 与开源解决方案的部署考量与成本博弈
人工智能·elasticsearch·zookeeper·rabbitmq·github·时序数据库·deepseek
-拟墨画扇-20 小时前
Git | Bug分支操作
git·gitee·github·bug·gitcode
CoderJia程序员甲21 小时前
GitHub 热榜项目 - 日榜(2025-12-27)
ai·开源·大模型·github·ai教程
Rhys..21 小时前
Jenkins配置GitHub token教程
运维·github·jenkins·ci
-拟墨画扇-1 天前
Git | Feature分支操作
git·gitee·github·gitcode