在尝试使用git filter-branch
来合并存储库时,使用此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-repo
,其说明如下:
重新组织文件布局(例如将所有文件移动到子目录中,以准备与另一个存储库合并,...)
这表明可以使用 git filter-repo
解决此问题,但即使在查看文档和给出的示例之后,我仍然找不到实现这一点的方法。请问有人能够帮我吗?
错误:使用--path-rename时,如果OLD_NAME和NEW_NAME都是非空的,并且其中任一个以斜杠结尾,则两者都必须这样。
- Saurabh P Bhandari