gpt4 book ai didi

git - 将 Git 存储库 A 移动到具有完整历史记录的 Git 存储库 B(非空)

转载 作者:太空狗 更新时间:2023-10-29 14:43:38 29 4
gpt4 key购买 nike

我想将我的所有文件从 Git Repo A 移动到 Git Repo B 并具有完整的历史记录。 Git B 已经包含另一个项目文件。我尝试了几种方法,例如

How to move files from one git repo to another (not a clone), preserving history

How to move files from one git repo to another preserving history using `git format-patch`and `git am`

我尝试通过终端执行所有提交。但是我在执行 git filter-branch --subdirectory-filter muDirectory -- --全部

我需要详细的指导和分步程序来将所有文件从一个存储库移动到另一个存储库。非常感谢任何帮助,提前致谢。

最佳答案

  • 进入repoB并使用 repoA URL 添加一个新的 Remote (比如说,repoA)。
  • 使用 branchA checkout 新分支(例如 repoA/master history) .
  • Git 将所有文件夹/文件移动到新的子目录中 RepoA .命令 git mv <src> <dest> .
  • branchA 中提交您的更改.
  • checkout master分支 merge branchA分支。

按照命令:

# go into repoB master branch
$ git remote add repoA <repoA-url>
$ git remote -v # confirm repoA is added named 'repoA'

$ git fetch repoA
$ git checkout -b branchA repoA/master
$ git mv <folder/file> repoA/<folder/file> # repeat untill all files/folders are moved
$ git commit -am 'Moved repoA folder/file into repoA dir'


$ git checkout master
$ git merge branchA

$ git add .
$ git commit -m 'Added repoA into repoA directory'
$ git push origin master

Git 子树:您可以使用 git subtree 执行此操作还有:

$ git subtree add --prefix=repoA/ <repoA-url> master

pull master branch of repoA进入名为 repoA 的子目录.

关于git - 将 Git 存储库 A 移动到具有完整历史记录的 Git 存储库 B(非空),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42061756/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com