... | ... | @@ -119,7 +119,44 @@ cd <gitlab_project> |
|
|
```
|
|
|
###### Post-processing for branches and tags
|
|
|
|
|
|
git-svn by default puts all subversion branches and tags in remote branches pointing to the original subversion repository, because git-svn is bi-directional, you can push to the svn repo. But in our case, let's say that:
|
|
|
* we want to migrate to git once and for all
|
|
|
* we want all subversion branches to end up as regular git branches
|
|
|
* we want all tags to end up as regular git tags
|
|
|
|
|
|
For this, there is a bit of post-processing involved before pushing to the new git repository:
|
|
|
|
|
|
*checkout branches*
|
|
|
|
|
|
Iterate all remote branches of the newly checked-out git-svn repository, filter out the tag branches, and checkout these branches, so that they are included when pushing to the new git remote:
|
|
|
|
|
|
```
|
|
|
for D in $(git branch -a | grep '^\s*remotes/' | grep -v '/tags/') ; do
|
|
|
git checkout -b "$(basename "$D")" "$D"
|
|
|
done
|
|
|
```
|
|
|
|
|
|
*convert tags*
|
|
|
|
|
|
Iterate all remote branches of the newly checked-out git-svn repository, if they are tag branches then create a git tag:
|
|
|
|
|
|
```
|
|
|
git for-each-ref refs/remotes/origin/tags |
|
|
|
while read REF ; do
|
|
|
SHA1=$(echo $REF | awk '{print $1}')
|
|
|
TAG=$(echo $REF | awk '{print $3}' | cut -d / -f 5- )
|
|
|
git tag "$TAG" "$SHA1"
|
|
|
done
|
|
|
```
|
|
|
|
|
|
*push everything*
|
|
|
|
|
|
Once all branches and tags are ready, instead of just pushing the master branch, push all branches and tags:
|
|
|
|
|
|
```
|
|
|
git push --force -u origin --all
|
|
|
git push --force -u origin --tags
|
|
|
```
|
|
|
|
|
|
##### Alternative methods
|
|
|
|
... | ... | |