[英]Copying one git repo to another repo with history
How to copy one repo entirely to another repo with history.如何将一个存储库完全复制到另一个具有历史记录的存储库。
I don't want to use fork or mirroring options, I tried out branch-filter options but it is limited to one directory.我不想使用 fork 或镜像选项,我尝试了分支过滤器选项,但它仅限于一个目录。 git filter-branch --subdirectory-filter /../RepoA/dire1
git filter-branch --subdirectory-filter /../RepoA/dire1
I was referring below url https://medium.com/@ayushya/move-directory-from-one-repository-to-another-preserving-git-history-d210fa049d4b/我指的是下面 url https://medium.com/@ayushya/move-directory-from-one-repository-to-another-preserving-git-history-d210fa049d4b/
Example: Source Target Requirement ------ ---- ------------------- RepoA RepoB(new Repo) Copy entire history - Dir1 - Dir1 - Dir2 - Dir2
Could you please suggest?你能建议吗?
You can try using the --index-filter
instead of the --subdirectory-filter
.您可以尝试使用
--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
Please checkout this thread for more information.请查看此线程以获取更多信息。
If RepoB is a fresh new repo.如果 RepoB 是一个全新的 repo。 Yon can also try below commands.
Yon 也可以尝试以下命令。 Clone RepoA to local machine, remove the remote origin of RepoA, then add the remote url to RepoB.
将 RepoA 克隆到本地机器,删除 RepoA 的远程源,然后将远程 url 添加到 RepoB。 see below example:
见下面的例子:
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
You can also try using git submodule.您也可以尝试使用 git 子模块。 Check the git document for more information.
查看git 文档了解更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.