gpt4 book ai didi

git - 如何使用git-filter-repo将一个仓库作为子目录 merge 到另一个仓库

转载 作者:行者123 更新时间:2023-12-03 16:18:26 28 4
gpt4 key购买 nike

在尝试使用git filter-branch merge 使用此gist的存储库时。仅添加相关的代码段:

git filter-branch -f --prune-empty --tree-filter '
mkdir -p "${REPO_NAME}_tmp"
git ls-tree --name-only $GIT_COMMIT | xargs -I{} mv {} "${REPO_NAME}_tmp"
mv "${REPO_NAME}_tmp" "$REPO_NAME"
'

我从git收到警告,内容如下:
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.

因此,我看了一下 git filter-repodescription指出以下内容:

restructuring the file layout (such as moving all files into a subdirectory in preparation for merging with another repo, ...



这表明可以使用 git filter-repo解决此问题,但是即使在检查了文档并给出了 examples之后,我仍然找不到实现该问题的方法。有人可以帮我吗?

最佳答案

在脚本中替换filter-branch命令

git filter-branch -f --prune-empty --tree-filter '
mkdir -p "${REPO_NAME}_tmp"
git ls-tree --name-only $GIT_COMMIT | xargs -I{} mv {} "${REPO_NAME}_tmp"
mv "${REPO_NAME}_tmp" "$REPO_NAME"
'

有了这个
git filter-repo --to-subdirectory-filter "$REPO_NAME"

请参见 路径快捷方式部分 here

--to-subdirectory-filter <directory>

Treat the project root as instead being under <directory>

Equivalent to using --path-rename :<directory>/

关于git - 如何使用git-filter-repo将一个仓库作为子目录 merge 到另一个仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61420660/

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