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
相关推荐
自来也_2 小时前
Git配置代理
git
Jooolin16 小时前
【编程史】Git是如何诞生的?这可并非计划之中...
linux·git·ai编程
Lw老王要学习21 小时前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
去旅行、在路上21 小时前
Git & Svn
git·svn
abcnull1 天前
github中main与master,master无法合并到main
git·github
养意1 天前
git提交代码和解决冲突修复bug
git·bug
码农黛兮_462 天前
Git 常用命令大全
git
一弓虽2 天前
git 学习
git·学习
疯狂的沙粒2 天前
如何通过git命令查看项目连接的仓库地址?
大数据·git·elasticsearch
qq_254617772 天前
Gerrit+repo管理git仓库,如果本地有新分支不能执行repo sync来同步远程所有修改,会报错
git