所以我在项目的前面有一个提交哈希。如何创建一个新的工作树并让它的分支从这个特定的提交开始?
答案 0 :(得分:2)
在worktree之前创建分支:
git branch newbranch $SHA1
git worktree add /path/to/wt newbranch
答案 1 :(得分:0)
使用the git worktree
documentation中描述的命令:
git worktree add [--detach] [-b< new-branch>]< path>并[d提交肥胖型>]
在这种情况下可能是,例如:
$ 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