0

I see lots of information about how to sync a git branch and an SVN branch, but I don't know how to check out an SVN tag in git.

I had hoped that I could maintain a demo branch in SVN that was always ready for unplanned customer demonstrations. I found out the hard way this morning that repeatedly merging from master to the demo branch won't work. (See https://stackoverflow.com/a/14173021/2596664.) I decided to try using svn copy to create tags called demo1, demo2, etc instead. Now I don't know how to access those tags from git. I told git I've used the standard SVN layout, but cannot find any information about how to access the tags part of SVN. How do I access it? If there's a better way to meet my requirement for "a demo branch in SVN that was always ready for unplanned customer demonstrations," I'd love to hear about it.

Community
  • 1
  • 1
Jim L.
  • 6,177
  • 3
  • 21
  • 47

1 Answers1

2

git-svn will translate SVN tags into Git tags for you, so long as you gave it the correct tags directory. Usually this is done with git svn init --tags=project/tags (assuming your project is laid out like that). The SVN tags will then be available as git tags. There's various options to git svn init to describe your SVN repository layout. If those weren't set up correctly, things aren't going to work.

You create tags in SVN from the git side using git svn tag tagname.

You can look at what idea git-svn has about your SVN repository layout in .git/config. Look for something like this:

[svn-remote "project-a"]
    url = http://server.org/svn
    fetch = trunk/project-a:refs/remotes/project-a/trunk
    branches = branches/*/project-a:refs/remotes/project-a/branches/*
    tags = tags/*/project-a:refs/remotes/project-a/tags/*
Schwern
  • 153,029
  • 25
  • 195
  • 336
  • "I told git I've used the **standard SVN layout**, but cannot find any information about how to access the tags part of SVN. **How do I access it?**" – Jim L. Feb 25 '15 at 21:29
  • @JimL. Repeating the question back to me isn't going to help, you're going to have to add clarity. What do you specifically mean by "access the tags part of SVN"? Do you want to list the tags? Create them? Delete them? – Schwern Feb 26 '15 at 08:01
  • What do I type to check out a tag, assuming the standard layout? – Jim L. Feb 26 '15 at 13:17
  • All SVN tags should be converted to Git tags, check it out like any other Git tag. `git checkout some_tag`. – Schwern Feb 26 '15 at 17:33
  • That doesn't work. `git checkout some_tag` gives me `error: pathspec some_tag did not match any file(s) known to git.` This tag does exist in SVN. – Jim L. Mar 09 '15 at 20:26
  • I got it to work with `git co refs/remotes/origin/tags/demo1`. Why can't I just type `git co demo1`? Looks like I have to at least type `git co origin/tags/demo1`. – Jim L. Mar 09 '15 at 20:41
  • @JimL. That implies to me that git-svn is treating the tags directory like branches and you're accessing a remote tracking branch. Check what `git config --get-all svn-remote.origin.tags` and `git config --get-all svn-remote.origin.branches` say. Also check `git tag -l` to see if the SVN tags are perhaps prefixed. – Schwern Mar 09 '15 at 22:10
  • @JimL. Then I believe you ran `git svn init` or `git svn clone` without the `-s` flag to tell it how to interpret the SVN tag and branch directories. I would suggest cloning the SVN repository again setting `-T`, `-b`, and `-t` explicitly. – Schwern Mar 11 '15 at 01:23