Git 备忘单

Git 是一个去中心化的版本管理软件。通过这个备忘单,您将可以快速访问最常见的 git 命令。

配置

设置全局配置

shell 复制代码
git config --global user.name "[name]"
git config --global user.email "[email]"

开始使用

创建 git 存储库

shell 复制代码
git init

克隆现有的 git 存储库

shell 复制代码
git clone [url]

犯罪

提交所有跟踪的更改

shell 复制代码
git commit -am "[commit message]"

向上次提交添加新的修改

shell 复制代码
git commit --amend --no-edit

我犯了一个错误

更改最后提交消息

shell 复制代码
git commit --amend

撤消最近的提交并保留更改

shell 复制代码
git reset HEAD~1

撤消N最近的提交并保留更改

shell 复制代码
git reset HEAD~N

撤消最近的提交并摆脱更改

shell 复制代码
git reset HEAD~1 --hard

将分支重置为远程状态

shell 复制代码
git fetch origin
git reset --hard origin/[branch-name]

各种各样的

将本地master分支重命名为main

shell 复制代码
git branch -m master main
相关推荐
CC码码1 小时前
管理你的多个 Git 密钥(多平台多账号)
git·gitlab·github
CC码码1 小时前
管理你的多个 Git 密钥(单平台多账号)
git·gitlab·github
大卫小东(Sheldon)1 小时前
GIM 1.5发布了! 支持Windows系统了
git·ai·rust
flying jiang1 小时前
将大仓库拆分为多个小仓库
git
李boyang9 天前
Git(四):远程操作
git
荻野泽溪9 天前
Git新建分支并同步到远程
git
漫步企鹅9 天前
【Git】新建一个远程分支的常规操作
git·新建远程分支
潇-xiao10 天前
Linux下的版本控制器Git(15)
linux·笔记·git
@昵称不存在10 天前
Git学习
git·学习
pe7er10 天前
⛔️⛔️⛔️丢弃本地commit,强制采用远端代码
git