[英]git subtree split - the tags are not transferred
I have a git project that has one big root directory: 我有一个git项目有一个很大的根目录:
C:\MyProject\MyProject
C:\MyProject\.git
And then all the files and subdirectories are inside C:\\MyProject\\MyProject
. 然后所有文件和子目录都在C:\\MyProject\\MyProject
。 I want to remove that redundant root directory, so I used this command: 我想删除那个多余的根目录,所以我使用了这个命令:
git subtree split -P MyProject -b MyBranch
git checkout MyBranch
git branch -D master
git branch -m MyBranch master
There is a problem with this solution, however - the tags are still attached to the now-deleted , original master branch: 但是,此解决方案存在问题 - 标记仍附加到现已删除的原始主分支:
The gray branch is the original master branch, the red branch is the new one without the redundant directory, but the tags are still attached to the old branch's checkins. 灰色分支是原始主分支,红色分支是没有冗余目录的新分支,但标记仍然附加到旧分支的签入。
git filter-branch
might be able to do the movement you want and migrate all branches and other references, like tags. git filter-branch
可能能够执行您想要的移动并迁移所有分支和其他引用,例如标记。 The --subdirectory-filter
will do an operation similar to the subtree that you are creating: --subdirectory-filter
将执行类似于您正在创建的子树的操作:
git filter-branch --prune-empty --subdirectory-filter subDirectory -- --all
Check this other answer for better detail on how to setup the repository for this kind of operation. 请查看此其他答案,以获取有关如何为此类操作设置存储库的更多详细信息。
I tried 我试过了
git filter-branch --prune-empty --subdirectory-filter <ProjectSubFolder>
--tag-name-filter cat -- --branches
That transfered the tags too but kept a dangling branch with tracking references so I removed by hand the file .git\\refs\\original\\refs\\heads\\master and the dangling branch dissappeared. 这也转移了标签,但保留了一个带有跟踪参考的悬挂分支,所以我手动删除文件.git \\ refs \\ original \\ refs \\ heads \\ master,悬空分支消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.