Git 全流程结构
Git 全流程结构
├─ 工作区(Working Directory)
│ ├─ 项目开发的地方(你正在编辑的文件)
│ └─ 相关命令:
│ ├─ git status
│ ├─ git diff
│ ├─ git add <file>
│ ├─ git checkout -- <file>
│ ├─ git restore <file>
│ └─ git stash
│
├─ 暂存区(Staging Area / Index)
│ ├─ 保存已 `add` 的文件,等待 `commit`
│ └─ 相关命令:
│ ├─ git add <file>
│ ├─ git restore --staged <file>
│ ├─ git reset HEAD <file>
│ └─ git diff --cached
│
├─ 本地仓库(Local Repository)
│ ├─ `.git` 中的 commit 历史
│ └─ 相关命令:
│ ├─ git commit -m "msg"
│ ├─ git log
│ ├─ git reset --soft HEAD~1
│ ├─ git reset --mixed HEAD~1
│ ├─ git revert <commit>
│ ├─ git cherry-pick <commit>
│ └─ git rebase <branch>
│
├─ origin/dev(远程跟踪分支)
│ ├─ 本地只读分支,代表远程 `dev` 的快照
│ └─ 相关命令:
│ ├─ git fetch origin dev
│ ├─ git diff dev..origin/dev
│ ├─ git merge origin/dev
│ ├─ git log origin/dev
│ └─ git rebase origin/dev
│
├─ stash 区(隐藏工作区/暂存区)
│ ├─ 用来临时保存当前未提交的工作(工作区/暂存区)
│ └─ 相关命令:
│ ├─ git stash
│ ├─ git stash pop
│ ├─ git stash apply
│ └─ git stash list
│
└─ 远程仓库(Remote Repository)
├─ 比如 GitHub / GitLab 上的主项目代码库
└─ 相关命令:
├─ git remote -v
├─ git push origin dev
├─ git pull origin dev
├─ git push -f
└─ git clone <repo-url>
思维导图

流程方向
git add git commit git push
工作区 ───────────▶ 暂存区 ────────────▶ 本地仓库 ──────────▶ 远程仓库
▲ │ │ │
│ git checkout │ git reset │ git reset │ git fetch
└──────────────────┴──────────────────┴──────────────────┘
流程图
