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
相关推荐
C++ 老炮儿的技术栈4 小时前
C/C++ 中 inline(内联函数)和宏定义(#define)的区别
开发语言·c++·git·算法·机器人·visual studio
Async Cipher6 小时前
Git 安装、配置
git
CoderJia程序员甲10 小时前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
莫问前路漫漫10 小时前
Electerm 连接远程服务器完整指南
运维·服务器·git
鸣弦artha11 小时前
TabBar标签页组件详解
linux·git·ubuntu
小林up15 小时前
Ubuntu访问不了Git解决办法
linux·git·ubuntu
月初,1 天前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄1 天前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
github.com/starRTC1 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github
CCC:CarCrazeCurator1 天前
git merge与rebase的区别及实操心得体会
git