一个Git存储库,两个工作树

时间:2012-11-09 17:01:07

标签: git msysgit

是否可以在同一本地存储库(== shared .git目录)中拥有两个工作树(两个不同的分支)?

3 个答案:

答案 0 :(得分:2)

可能替换可能有助于在多个.git / -directories之间共享一个对象存储。在以下位置检查“对象/信息/替换”:

http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html

答案 1 :(得分:2)

是。但是你需要将第二个分支workdir放在第二个目录中,并手动管理交换。

请参阅Git man page

--work-tree=<path>
Set the path to the working tree. It can be an absolute path or a path relative
to the current working directory. This can also be controlled by setting the 
GIT_WORK_TREE environment variable and the core.worktree configuration variable 
(see core.worktree in git-config(1) for a more detailed discussion).

这允许您根据需要签出任意数量的工作树/目录,并以任何顺序检查它们,反对您声称已经签出的分支。

但如果你犯了一些错误,不要感到惊讶。这有点像用剪刀跑。

答案 2 :(得分:1)

不,你必须制作两个克隆。

相关问题