小编goo*_*ude的帖子

filter-branch --tree-filter之后从git repo中删除refs/original/heads/master?

我遇到了与此处提出的问题相同的问题:根目录中的新git存储库包含子目录中的存在存储库

我在这里听到了这个答案:根目录中的新git存储库包含子目录中的存在存储库

现在,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'
Run Code Online (Sandbox Code Playgroud)

现在我们有原始海报的问题.让我们使用上面链接的答案将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
Run Code Online (Sandbox Code Playgroud)

现在,看看我目前的问题:

gitk …
Run Code Online (Sandbox Code Playgroud)

git git-rewrite-history git-plumbing

166
推荐指数
3
解决办法
4万
查看次数

标签 统计

git ×1

git-plumbing ×1

git-rewrite-history ×1