将一个git repo复制到另一个有历史记录的 repo上。

问题描述 投票:0回答:1

如何将一个repo完全复制到另一个有历史记录的repo。

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

我说的是下面的网址https:/medium.com@ayushyamove-directory-from-one-repository-to-another-preservation-git-history-d210fa049d4b。

能否请您建议一下?

git azure-devops
1个回答
0
投票

你可以尝试使用 --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

请结账 这条 以获取更多信息。

如果RepoB是一个新的repo,你也可以尝试以下命令。你也可以试试下面的命令。将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文档 更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.