【问题标题】:Copying one git repo to another repo with history将一个 git 存储库复制到另一个具有历史记录的存储库
【发布时间】:2020-06-12 18:21:44
【问题描述】:

如何将一个存储库完全复制到另一个具有历史记录的存储库。

我不想使用 fork 或镜像选项,我尝试了分支过滤器选项,但它仅限于一个目录。 git filter-branch --subdirectory-filter /../RepoA/dire1

我指的是下面的网址 https://medium.com/@ayushya/move-directory-from-one-repository-to-another-preserving-git-history-d210fa049d4b/

例子: 源目标要求 ------ ---- -------- RepoA RepoB(new Repo) 复制整个历史 - 目录 1 - 目录 1 - 目录 2 - 目录 2

你能推荐一下吗?

【问题讨论】:

  • 这里有什么帮助吗? stackoverflow.com/…
  • submodulesubtree?我不确定你的问题是什么。如果你解释一下你为什么或你想要达到的目标,也许会更好。
  • 您好,下面的回答对您有帮助吗?上面的情况如何?

标签: git azure-devops


【解决方案1】:

您可以尝试使用--index-filter 而不是--subdirectory-filter

$ git filter-branch --index-filter \
    'git ls-files -s | sed "s#\t#&RepoA/#" |
     GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
     git update-index --index-info &&
     mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD

请查看this thread了解更多信息。

如果 RepoB 是一个全新的 repo。 Yon 也可以尝试以下命令。将 RepoA 克隆到本地计算机,删除 RepoA 的远程源,然后将远程 url 添加到 RepoB。看下面的例子:

git clone http:/url/repoA
cd repoA
git pull origin branchName
git remote remove origin
git remote add origin http:/url/repoB
git push -u origin --all

您也可以尝试使用 git 子模块。更多信息请查看git document

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 2017-11-30
    • 2013-06-26
    • 2023-04-09
    • 1970-01-01
    • 2013-01-25
    • 2011-04-08
    相关资源
    最近更新 更多