admin管理员组

文章数量:1240593

we have a huge monolithic repository in the form of

master-repo
  |-- libraries
  |-- db-backend
  |    |-- plsql
  |    |-- data
  |    `-- scripts
  |-- server-backend
  |-- ...
  `-- frontent

including multiple branches and versions accumulated over time and may look like this:

commit    tag      message
cf068d3d  ver-2.0  release build
315a01c6           fix issue in frontend
401b6520           add feature to server-backend
eed705bd           fix issue in db-backend
f9c0c94e  ver-1.9  release build
7c5c56d2           add feature to db-backend
63affce3           add feature to db-backend
21385a5c           add feature to server-backend
c9fc18ea           fix issue in frontend
2a732d25  ver-1.8  release build
788e59a6           merge from branch toto
77c88fed           fix issue in db-backend
...
fbd4703f  ver-0.1  release build

The goal is to split this into several smaller repos like:

db-backend
  |-- plsql
  |-- data
  `-- scripts

I was first trying to use something like

git filter-branch --index-filter 'git ls-files \
| grep -v "^db-backend/" \
| xargs --no-run-if-empty git rm --cached' HEAD

But I was running in a couple of issues including problems with large files or that some files didn't got cleaned up etc.

So instead I then used git subtree split --prefix db-backend/ --branch split_db_backend which works a lot better, however I am loosing all the tags which are indeed associated to commit on the root of the repository.

The subtree command doesn't seem to have any additional options related to tags, so I assume I have to create a small batch to loop over all commits in the original repo branch and search for commits containing in the resulting branch and then manual re-tag them.

But I struggle with creating a command to find the latest tag which includes my commit in the split, and doing this only on the latest commit in the history (to avoid tagging all commits in the history).

For example, if I would loop over the resulting commits in the generated subtree split using for tag in 'git tag -l --contains eed705bd\' do I would get all commits and tags down to tag ver-0.1, but this change was actually only included in tag ver-2.0

Any help would be appreciated.

本文标签: git tagHow to take over tags from git master branch into subtree splitStack Overflow