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
相关推荐
幸运的大号暖贴1 小时前
解决Vibe Coding时Idea经常不自动git add问题
java·人工智能·git·intellij-idea·claudecode·opencode
摇滚侠2 小时前
如何打开 GitHub,GitHub 是基于 Git 版本控制系统的在线代码托管平台
git·github
MY_TEUCK3 小时前
【Git 实习生小白专用】:最安全、永不翻车、公司最爱 的标准版本控制工作流程
git·安全·github
donecoding4 小时前
第一次用 git worktree,连踩了三个坑(附无痛清理姿势)
git
spmcor4 小时前
解决 Git 中已跟踪目录无法被 .gitignore 忽略的问题
git
qcx236 小时前
【AI Engineering · Harness 系列】02 确定性外壳 × 非确定性内核——git push 红线的故事
人工智能·git·prompt·agent·engineering·harness
水云桐程序员6 小时前
10 分钟 Git 上手教程
git
Dontla6 小时前
Git三个主要区域介绍(工作区Working Directory、暂存区Index/Staging Area、仓库区Repository)
git
她说可以呀7 小时前
git在Ubuntu的下载和配置用户
git·ubuntu
隔窗听雨眠7 小时前
Git二分法精准定位Bug
git·bug·git bisect