Git 多工作区管理
git worktree 让同一个仓库同时检出多个目录,共享 .git 对象库。适合一边开发一边 hotfix,或同时构建多个分支,不用反复 stash。
git worktree add ../app-hotfix -b hotfix
git worktree add ../app-review origin/main
git worktree list
git worktree remove ../app-hotfix
git worktree prune
git worktree lock ../app-review
git worktree unlock ../app-review
git worktree move ../app-review ../review
git worktree remove;直接 rm -rf 会留下元数据,用 prune 清理。lock 用于移动磁盘或临时保留;忘记解锁会让 prune 跳过它。submodule update。git — 版本控制git-stash — 临时保存改动git-submodule — 子模块