GitHub的使用

环境准备

创建仓库

生成token

目前的github上传,不在支持密码,需要使用token

生成本地密钥

ssh-keygen -t rsa -C "email"

查看生成的密钥

将密钥添加到github

代码拉取、推送

初始化本地仓库

git init

将远端仓库与本地仓库链接起来

添加远程配置

git remote add origin https://github.com/\<username>/<repo>.git

git remote set-url origin https://\<your_token\>@github.com/\<username>/<repo>.git

  • <your_token>:刚刚生成的token
  • <username>:github的用户名
  • <repo>:仓库名称

将当前目录下的所有修改过的文件添加到 Git 的暂存区

git add .

绑定邮箱和用户名(先输入下面的第一次创建时的代码)

第一次创建时

git config --global user.name "你的用户名"

git config --global user.email "你的邮箱"

要修改时

git config --replace-all user.name "你的用户名"

git config --replace-all user.email "你的邮箱"

查看当前仓库配置信息

git config --list

查看全局配置信息

git config --global -l

按q退出

将暂存区中的修改提交到本地仓库,并添加提交信息

git commit -m "test"

将当前分支重命名为 main

git branch -M main

拉取分支

git pull --rebase origin main

将本地 main 分支推送到远程仓库,并设置该分支的上游(upstream)跟踪关系

git push --set-upstream origin main

推送

git push

github加速

win自带的商店里面直接搜索Watt Toolkit安装

相关推荐
前端市界3 小时前
用 React 手搓一个 3D 翻页书籍组件,呼吸海浪式翻页,交互体验带感!
前端·架构·github
happyprince3 小时前
2026年02月07日热门github项目
github
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2026-02-06)
人工智能·ai·大模型·github·ai教程
荔枝吻5 小时前
忘记服务器密码,在Xshell7中查看已保存密码
运维·服务器·github
tod1138 小时前
TCP全连接队列与tcpdump抓包
网络·网络协议·tcp/ip·github·tcpdump
Luck_ff08108 小时前
百度指数数据采集与可视化平台 BaiduIndexHunter
github·开源软件
阿里嘎多学长8 小时前
2026-02-03 GitHub 热点项目精选
开发语言·程序员·github·代码托管
子兮曰15 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
m0_694845571 天前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp
June`1 天前
muduo项目排查错误+测试
linux·c++·github·muduo网络库