git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Handling tags/branches after git-svn fetch during SVN to Git conversion

From
Bradley Wagner <bradley.wagner@hannonhill.com>
Date
Jul 7, 2010, 13:36 UTC
Message-ID
<AANLkTim56UOYQJfX3M5Jpt0vXD8iTnkLuG68IjQG39Xn@mail.gmail.com>

I had a fairly complicated config for my SVN to Git migration with multiple branch and tag locations. Therefore, I had to break up the "git svn clone" because I didn't know how to pass multiple branch locations to "git svn clone":

1. git svn init
2. Update .git/config with branch/tag locations
[svn-remote "svn"]
        url = file:///Users/Developers/git_transition/svn_repo
        fetch = project/trunk:refs/remotes/svn/trunk
        branches =
project/branches/{feature1-branch,feature2-branch}:refs/remotes/svn/*
        branches =
project/branches/{6.x,5.x,4.x,3.x,archive}/*:refs/remotes/svn/*
        tags = project/tags/{3.7.x,4.x,5.x,6.x,old-releases}/*:refs/remotes/svn/tags/*
3. git svn -A/path/to/mappings fetch

Do I need to convert these remote tags/branches into local Git tags/branches before pushing them to my remote Git repo or is there a way to push remote branches directly to my remote Git repo?

The command that someone else told me was "git checkout -b <local_branch_name> <remote_branch_name>". Though, I've seen other places mention different strategies for converting the branches.

The script I devised to convert the tags does this for each tags folder to maintain the original commit date, author, and commit message:

git for-each-ref --format="%(refname)" refs/remotes/svn/tags/6.x | grep -v @ | while read tag; do GIT_COMMITTER_DATE="$(git log -1 --pretty=format:"%ad" "$tag")" GIT_COMMITTER_EMAIL="$(git log -1 --pretty=format:"%ce" "$tag")" GIT_COMMITTER_NAME="$(git log -1 --pretty=format:"%cn" "$tag")" git tag -m "$(git log -1 --pretty=format:"%s%n%b" "$tag")" ${tag#refs/remotes/svn/tags/6.x/} "$tag"; done

Please let me know if this is correct.
Thanks!
Next: Bradley Wagner
Message 1 of 7 in “Handling tags/branches after git-svn fetch during SVN to Git conversion”
  1. Bradley WagnerJul 7, 2010
  2. Bradley WagnerJul 9, 2010
  3. Jacob HelwigJul 9, 2010
  4. Bradley WagnerJul 9, 2010
  5. Jacob HelwigJul 9, 2010
  6. Bradley WagnerJul 9, 2010
  7. Jacob HelwigJul 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.