如何将本地 git 存储库与其工作目录分离?
这可行吗?
我希望将 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以设置
GIT_DIR环境变量
:
如果由于某种原因设置环境变量不可行,您可以使用
--git-dir
选项 与任何 git 命令:You can set the
GIT_DIR
environment variable:If setting an environment variable is infeasible for any reason, you can use the
--git-dir
option with any git command:我真的建议将您的整个存储库保存在您首选的驱动器上。然后,您可以将一个裸仓库放在无法控制的驱动器上,然后推送到它。这是最大程度地减少与不良存储的交互的最佳方法。
如果出于某种原因您必须跨驱动器拆分存储库,为什么不在一个驱动器上创建存储库,将 .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.