场景示例
正在跑测试任务的分支,来了hotfix,这个时候可以:- stash
- 或者checkout一个hotfix分支,这个时候就能用 worktree
脚本示例
# [dev]
git commit -a -m "dev commit"
# checkout new branch in other directory
git worktree add -f ../hotfix -b hotfix
# do hotfix
...
# clean worktree
gir worktree remove ../hotfix
FAQ
- 相比stash改进?- (新目录分支,100%不干扰)
- 相比remote checkout改进?- (速度快,无需远程分支)