我目前正在将 cvs 项目导入 git。
导入后,我想重写历史记录以将现有目录移动到单独的子模块中。
假设我有这样的结构:
file1
file2
file3
dir1
dir2
library
现在我想重写历史记录,以便该目录library
始终是 git 子模块。比如说,将指定的目录拆分为它们自己的子模块/子项目
这是我当前的代码:
文件重写子模块(被调用)
cd project
git filter-branch --tree-filter $PWD/../$0-tree-filter --tag-name-filter cat -- --all
Run Code Online (Sandbox Code Playgroud)
文件重写子模块树过滤器
#!/bin/bash 函数 gitCommit() { 取消设置 GIT_DIR 取消设置 GIT_WORK_TREE git添加-A if [ -n "$(git diff --cached --name-only)" ] 然后 # 需要提交的东西 git 提交 -F $_msg 菲 } _git_dir=$GIT_DIR _git_work_tree=$GIT_WORK_TREE 取消设置 GIT_DIR 取消设置 GIT_WORK_TREE _dir=$PWD 如果[-d“库”] 然后 _msg=$(临时文件) git 日志 ${GIT_COMMIT}^! --format="%B" > $_msg git rm -r --缓存库 光盘库 …
git url-rewriting subproject git-submodules git-filter-branch