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安装

相关推荐
m0_694845575 小时前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp
June`5 小时前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
weixin_6687 小时前
GitHub 2026年AI项目详细数据汇总表-AI分析-分享
人工智能·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
weixin_6681 天前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
MicrosoftReactor1 天前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~9701 天前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
m0_694845571 天前
music-website 是什么?前后端分离音乐网站部署实战
linux·运维·服务器·云计算·github
独自破碎E1 天前
已经 Push 到远程的提交,如何修改 Commit 信息?
开发语言·github
jiang_changsheng1 天前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别