GIT多个本地签出 [英] GIT multiple local checkouts

查看:102
本文介绍了GIT多个本地签出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一台计算机(Linux和Windows)上签出同一个git repostiory的多个分支。然而,由于版本库可能非常庞大,我宁愿拥有一个版本库,也只有多个工作目录。



这可能吗?
如何如此?

解决方案

这是可能的,因为Git 2.5和它的 git worktree 命令。



它取代了旧脚本 contrib / workdir / git-new-workdir ,使用更强大的机制,那些链接的工作树实际上被记录在主要的仓库新的 $ GIT_DIR / worktrees 文件夹中(这样可以在包括Windows在内的任何操作系统上运行)。

一旦你克隆了一个repo(在像 / path / to / myrepo 的文件夹中),你可以添加不同独立路径( / path / to / br1 / path / to / br2 code>),同时让那些工作树链接到主repo历史记录中(不再需要使用 - git-dir 选项)



请参阅使用Git的多个工作目录?


I want to checkout multiple branches of the same git repostiory on the same Computer (Linux and Windows). However as the repository might be huge, I would prefer to have the repository once and only multiple working directories.

Is this possible? How so?

解决方案

It is possible since Git 2.5 and its git worktree command.

It replaces an older script contrib/workdir/git-new-workdir, with a more robust mechanism where those "linked" working trees are actually recorded in the main repo new $GIT_DIR/worktrees folder (so that work on any OS, including Windows).

Once you have cloned a repo (in a folder like /path/to/myrepo), you can add worktrees for different branches in different independent paths (/path/to/br1, /path/to/br2), while having those working trees linked to the main repo history (no need to use a --git-dir option anymore)

See "Multiple working directories with Git?"

这篇关于GIT多个本地签出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆