6

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

4

3 回答 3

2

在这里,替代品可能有助于在多个 .git/- 目录之间共享一个对象存储。在以下位置检查“对象/信息/替代”:

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

于 2012-11-09T19:31:05.567 回答
2

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

请参阅Git 手册页

--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).

这使您可以根据需要签出任意数量的工作树/目录,并根据您声称已经签出的任何分支以任何顺序将它们签入。

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

于 2012-11-09T19:32:04.537 回答
1

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

于 2012-11-09T17:56:09.223 回答