【问题标题】:git move portion of old repository to a new repositorygit 将旧存储库的一部分移动到新存储库
【发布时间】:2012-10-19 13:46:50
【问题描述】:

我有一个包含多个根目录的存储库,例如

gitroot/a
gitroot/b
gitroot/c

我想仅从 a 的内容创建一个新的 git 存储库,同时保留其历史记录。这可能吗?我已经看到了稀疏的签出,但我不确定如何使用它从子目录创建一个全新的存储库(具有相关历史记录)。

【问题讨论】:

    标签: git repository sparse-checkout


    【解决方案1】:

    克隆现有存储库后,您可以使用filter-branch

    git filter-branch --subdirectory-filter a -- --all
    

    在那之后;

    git clean -d -f  // Remove untracked files from the working tree
    git gc --aggressive // Cleanup unnecessary files and optimize the local repository
    git prune  // Prune all unreachable objects from the object database
    

    【讨论】:

      猜你喜欢
      • 2011-06-30
      • 2021-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      相关资源
      最近更新 更多