在尝试使用时git filter-branch
使用此合并存储库gist https://gist.github.com/icholy/6491787bbb6894dbf4fe69a743975332。仅添加相关的相关片段:
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
, the 描述 https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#DESCRIPTION陈述如下:
重组文件布局(例如将所有文件移动到子目录中以准备与另一个存储库合并,...
这表明这个问题可以通过以下方式解决git filter-repo
,但即使在检查文档并给出之后examples https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#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"
See 路径快捷方式部分here https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#OPTIONS
--到子目录过滤器<directory>
将项目根视为位于<directory>
相当于使用--path-rename :<directory>/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)