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
相关推荐
原来是猿6 小时前
进程间通信(三):命名管道
linux·服务器·网络·git
幸福从心动开始6 小时前
脱单不是拖,爱要主动说——写给还在“git commit -m ‘等缘分’”的程序员
git
弹简特9 小时前
【测试基础】11-软件测试之测试方案编写&测试报告编写&Git工具安装
git·功能测试
吴声子夜歌1 天前
TypeScript——泛型
前端·git·typescript
春日见1 天前
3三分彻底了解Git Graph极其应用
git
风.foxwho1 天前
jenkins使用 ED25519密钥 拉取Git 代码 配置
git·servlet·jenkins
ruanCat1 天前
前端工程化工具链从零配置:simple-git-hooks + lint-staged + commitlint
前端·git·代码规范
木子小喵1 天前
Git的使用介绍!超通俗!
git
coderYYY1 天前
git push报错Authentication failed for ‘xxx’也不会弹要求输入用户名密码的最终解决方法
前端·git·gitee·github
@PHARAOH1 天前
WHAT - git worktree 开发的并发模型
大数据·git·elasticsearch