【发布时间】:2011-12-01 01:46:40
【问题描述】:
我也有同样的问题:New git repository in root directory to subsume an exist repository in a sub-directory
我在这里关注了这个答案:New git repository in root directory to subsume an exist repository in a sub-directory
现在,gitk --all 显示了两个历史记录:一个在当前的 master 中达到高潮,另一个名为 original/refs/heads/master。
我不知道这第二个历史是什么,或者如何从回购中删除它。我的存储库中不需要两个历史记录。
我该如何摆脱它?
复制自己:
mkdir -p project-root/path/to/module
cd project-root/path/to/module
mkdir dir1 dir2 dir3
for dir in * ; do touch $dir/source-file-$dir.py ; done
git init
git add .
git commit -m 'Initial commit'
现在我们遇到了原始海报的问题。让我们使用上面链接的答案将 git repo 的根目录移动到 project-root:
git filter-branch --tree-filter 'mkdir -p path/to/module ; git mv dir1 dir2 dir3 path/to/module' HEAD
rm -rf path
cd ../../../ # Now PWD is project-root
mv path/to/module/.git .
git reset --hard
现在,看看我目前的问题:
gitk --all &
git show-ref
如何删除 refs/original/heads/master 和所有相关历史记录?
【问题讨论】:
标签: git git-rewrite-history git-plumbing