git 工作树添加 [来自特定的提交哈希]
git worktree add [from specific commit hash]
所以我有一个项目早期的提交哈希。我如何创建一个新的工作树并让它的分支从此特定提交开始?
在工作树之前创建分支:
git branch newbranch $SHA1
git worktree add /path/to/wt newbranch
使用the git worktree
documentation中描述的命令:
git worktree add [--detach] [-b <new-branch>] <path> [<commit-ish>]
在这种情况下可能是,例如:
$ cd gitrepo
$ git worktree add -b workbranch ../gitrepo.workbranch d16c37964
Preparing ../gitrepo.workbranch (identifier gitrepo.workbranch)
HEAD is now at d16c37964 Merge branch 'jk/attributes-path-doc'
之后:
$ cd ../gitrepo.workbranch
$ git status
On branch workbranch
nothing to commit, working tree clean
$ git rev-parse HEAD
d16c37964c284fa599251caafb51128c0df925a9
所以我有一个项目早期的提交哈希。我如何创建一个新的工作树并让它的分支从此特定提交开始?
在工作树之前创建分支:
git branch newbranch $SHA1
git worktree add /path/to/wt newbranch
使用the git worktree
documentation中描述的命令:
git worktree add [--detach] [-b <new-branch>] <path> [<commit-ish>]
在这种情况下可能是,例如:
$ cd gitrepo
$ git worktree add -b workbranch ../gitrepo.workbranch d16c37964
Preparing ../gitrepo.workbranch (identifier gitrepo.workbranch)
HEAD is now at d16c37964 Merge branch 'jk/attributes-path-doc'
之后:
$ cd ../gitrepo.workbranch
$ git status
On branch workbranch
nothing to commit, working tree clean
$ git rev-parse HEAD
d16c37964c284fa599251caafb51128c0df925a9