如何将本地 git 存储库与其工作目录分离?

发布于 2024-09-14 05:34:06 字数 303 浏览 1 评论 0原文

这可行吗?

我希望将 .git 目录放在除结帐目录之外的另一个驱动器上。 我找不到一种方法来分离两者。

原因是:在非常慢的网络驱动器和有限的空间上有一个交换区域,这是一个真正的超时噩梦。至少可以足够快地完成存储库操作(与 svn 存储库同步)以避免超时,并且可以在签出后完成文件复制,但性能较差。我找不到任何方法来应对这种情况(这是我无法控制的),

我不想这样做,但如果没有更好的建议,我会用本地 git 存储库替换它,并在两个方向上 rsync'ing 结帐目录往返慢速行驶。

我打赌你有更好的主意!

Is this feasible?

I would like to have the .git directory on another drive than the checkout directory.
I could not find a way to detach both.

The reason is: there is an exchange area on a very slow network drive and limited space and this is a real nightmare with timeouts. At least the repository operations (synchronization with a svn repository) could then be done fast enough to avoid the timeouts and file copy can be done afterwards on checkout with the poor performance. I could not find any way to cope with this situation (which is out of my control)

I would not like to but if there is no better suggestion I would replace it by a local git repository and rsync'ing the checkout dir in both directions to and from the slow drive.

I bet you have a better idea!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒儿 2024-09-21 05:34:06

您可以设置GIT_DIR环境变量

如果设置了 $GIT_DIR 环境变量,则它会指定要使用的路径,而不是 ./.git 作为存储库的基础。

如果由于某种原因设置环境变量不可行,您可以使用 --git-dir 选项 与任何 git 命令:

--git-dir=<路径>;

设置存储库的路径。这也可以通过设置 GIT_DIR 环境变量来控制。它可以是当前工作目录的绝对路径或相对路径。

You can set the GIT_DIR environment variable:

If the $GIT_DIR environment variable is set then it specifies a path to use instead of ./.git for the base of the repository.

If setting an environment variable is infeasible for any reason, you can use the --git-dir option with any git command:

--git-dir=<path>

Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.

我真的建议将您的整个存储库保存在您首选的驱动器上。然后,您可以将一个裸仓库放在无法控制的驱动器上,然后推送到它。这是最大程度地减少与不良存储的交互的最佳方法。

如果出于某种原因您必须跨驱动器拆分存储库,为什么不在一个驱动器上创建存储库,将 .git 目录移动到另一个驱动器,然后将存储库中的 .git 符号链接到重新定位的 .git 目录。 git 目录。

I'd really suggest keeping your entire repo on your preferred drive. You can then put a bare repo on the beyond-your-control drive, and push to it. This is the best way to minimize your interactions with the bad storage.

If for some reason you must split a repo across drives, why not just create the repo on one drive, move the .git directory to the other drive, then symlink .git in your repo to the relocated .git directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文