From 93a5182d1a595095ec89553804c606180d19018f Mon Sep 17 00:00:00 2001 From: Mira <163523387+Mira190@users.noreply.github.com> Date: Thu, 18 Sep 2025 20:57:36 +1000 Subject: [PATCH] Create git-101.mdx --- app/docs/CommunityShare/Geek/git-101.mdx | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/docs/CommunityShare/Geek/git-101.mdx diff --git a/app/docs/CommunityShare/Geek/git-101.mdx b/app/docs/CommunityShare/Geek/git-101.mdx new file mode 100644 index 0000000..71f9696 --- /dev/null +++ b/app/docs/CommunityShare/Geek/git-101.mdx @@ -0,0 +1,40 @@ +--- +title: Git Cheat Sheet +description: +date: 2025-09-18 +tags: [] +--- + + +## GIT 最常用命令 +| Basic 基础 | Branch & Remote 协作 | +|------------|----------------------| +| `git init ` → 初始化仓库 | `git branch` → 分支列表/新建分支 | +| `git clone ` → 克隆远程仓库 | `git checkout -b ` → 新建并切换分支 | +| `git add ` → 暂存文件 | `git merge ` → 合并分支 | +| `git commit -m "msg"` → 提交更改 | `git pull ` → 拉取并合并远程 | +| `git push ` → 推送分支 | `git remote add ` → 添加远程 | +| `git status` → 查看文件状态 | `git fetch ` → 获取远程分支 | +| `git log --oneline` → 单行历史 | `git pull --rebase ` → 拉取并 rebase | +| `git diff` → 查看未暂存差异 | `git push --tags` → 推送所有标签 | + + + +## GIT其他命令 +| Undo / Reset / Log / Diff | Config / Advanced Push / Rebase | +|---------------------------|---------------------------------| +| `git commit --amend` → 修改上次提交 | `git config user.name ` → 设置仓库作者名 | +| `git revert ` → 撤销提交 | `git config --global user.name ` → 全局作者名 | +| `git reset ` → 从暂存区移除文件 | `git config --global user.email ` → 全局邮箱 | +| `git reset --soft ` → 回退提交,保留暂存和工作区 | `git config --global alias. ` → 创建别名 | +| `git reset --mixed ` → 回退提交,保留工作区(默认) | `git config --system core.editor ` → 设置编辑器 | +| `git reset --hard ` → 回退提交,丢弃修改 | `git config --global --edit` → 编辑全局配置 | +| `git clean -n` → 预览删除未跟踪文件 | `git push --force` → 强制推送(危险) | +| `git reflog` → 查看 HEAD 历史 | `git push --all` → 推送所有分支 | +| `git log -` → 限制提交数量 | `git rebase ` → 将分支变基 | +| `git log --stat` → 文件修改统计 | `git rebase -i ` → 交互式变基 | +| `git log -p` → 提交详细 diff | `git rebase --continue` → 继续变基(解决冲突后) | +| `git log ..` → 指定范围历史 | `git rebase --abort` → 中止变基 | +| `git log -- ` → 某文件历史 | `git log --author=""` → 按作者搜索 | +| `git diff HEAD` → 工作区 vs 最近提交 | `git log --grep=""` → 按说明搜索 | +| `git diff --cached` → 暂存区 vs 最近提交 | `git log --graph --decorate` → 图形化历史 |