Dev Patrache

Git 速查表

Setup

Safe
git config --global user.name "Name"

Set user name

git config --global user.name "Sam"

Safe
git config --global user.email "email"

Set email

git config --global user.email "[email protected]"

Safe
git config --list

Show all config

git config --list

Start

Safe
git init

Initialize a new repository

git init my-project

Safe
git clone <url>

Clone a remote repository

git clone https://github.com/user/repo.git

Changes

Safe
git status

Working directory status

git status

Safe
git diff

Compare changes

git diff HEAD~1

Safe
git add <file>

Add to staging

git add . / git add file.txt

Safe
git commit -m "message"

Create a commit

git commit -m "feat: new feature"

Caution
git commit --amend

Amend the last commit

git commit --amend -m "updated message"

Safe
git stash

Temporarily stash changes

git stash / git stash pop

Branch

Safe
git branch

List branches

git branch -a

Safe
git branch <name>

Create a new branch

git branch feature/login

Safe
git checkout <branch>

Switch branch

git checkout main

Safe
git checkout -b <name>

Create and switch

git checkout -b feature/login

Caution
git merge <branch>

Merge a branch

git merge feature/login

Caution
git branch -d <name>

Delete a branch

git branch -d feature/login

Danger
git branch -D <name>

Force-delete a branch

git branch -D feature/login

Remote

Safe
git remote -v

List remotes

git remote -v

Safe
git fetch

Fetch remote changes

git fetch origin

Caution
git pull

Fetch and merge

git pull origin main

Caution
git push

Push to remote

git push origin main

Danger
git push --force

Force push

git push --force origin main

Undo

Caution
git restore <file>

Discard file changes

git restore file.txt

Safe
git reset HEAD <file>

Unstage a file

git reset HEAD file.txt

Safe
git revert <commit>

Revert a commit (new commit)

git revert abc123

Caution
git reset --soft HEAD~1

Undo last commit (keep changes)

git reset --soft HEAD~1

Danger
git reset --hard HEAD~1

Delete last commit (discard changes)

git reset --hard HEAD~1

Inspect

Safe
git log

Commit history

git log --oneline --graph

Safe
git log --oneline

One-line history

git log --oneline -10

Safe
git show <commit>

Commit details

git show abc123

Safe
git blame <file>

Per-line author

git blame file.txt

Safe
git reflog

HEAD history (for recovery)

git reflog

最后更新:2026 · 免费在线工具

什么是 Git 速查表?

免费在线Git速查表,按类别整理可搜索的常用命令,涵盖分支、合并、rebase、stash和reset,每条附带语法说明并标注危险等级,避免误删提交。 可在编码时于一处快速查阅代码、符号、快捷键等参考信息,在浏览器中即时搜索和复制,无需注册或安装即可免费使用。 结果可一键复制,整个过程简单快捷,无需下载任何软件,在手机和电脑上都能随时流畅使用。

使用方法

  1. 1
    输入— 输入所需数据。
  2. 2
    结果— 查看处理结果。
  3. 3
    复制— 复制结果使用。

相关工具

正则表达式速查表按元字符、量词、锚点、分组等类别整理正则表达式语法,支持搜索和一键复制模式,并兼容JavaScript正则表达式的免费正则速查表 适用于编写和测试正则表达式、SQL、代码格式化等开发工作,全部在浏览器本地处理,代码不会上传服务器,无需安装或注册即可免费使用。 结果可一键复制,整个过程简单快捷,无需下载任何软件,在手机和电脑上都能随时流畅使用。
HTML 实体参考免费在线HTML实体参考,按类别列出命名和数字字符代码,涵盖箭头、货币、数学符号等,可按名称或符号搜索,一键复制实体代码到网页中使用。 可在编码时于一处快速查阅代码、符号、快捷键等参考信息,在浏览器中即时搜索和复制,无需注册或安装即可免费使用。 结果可一键复制,整个过程简单快捷,无需下载任何软件,在手机和电脑上都能随时流畅使用。
Linux 命令参考免费在线 Linux 命令参考工具,按文件、进程、网络等类别整理常用命令,搜索即可查到选项与用法示例,附带说明帮助你快速记忆并提升终端操作效率。 可在编码时于一处快速查阅代码、符号、快捷键等参考信息,在浏览器中即时搜索和复制,无需注册或安装即可免费使用。 结果可一键复制,整个过程简单快捷,无需下载任何软件,在手机和电脑上都能随时流畅使用。

常见问题

是的,因为使用静态数据所以可以离线使用。

本站使用 Cookie 以改善体验和投放广告。 了解更多