Friday, March 1, 2013

Git-SVN

Here are some notes when I play with git-svn:
  • Clone a project. You can run the following commands if the project follows the standard layout with trunk/tags/branches.
    root
      |- ProjectA
      |   |- branches
      |   |- tags
      |   \- trunk
      |- OtherProject
    
  • Download trunk, tags and branches. You will find the same directories just like SVN repository.
    git svn clone -r XXXX https://subversion.mycompany.com/ProjectA
    
  • init a new project. This will create dir projectA and initializ it as a git repository.
    git svn init https://subversion.mycompany.com/projectA projectA
    
  • Download trunk only. The directory have the files under trunk only.
    git svn clone -s -r XXXX https://subversion.mycompany.com/ProjectA
    • Provide the revision number using "-r xxxx", otherwise have to wait for a long time until git-svn finishes scanning all revisions.
    • Use the revision of the project (96365) instead of the latest revision (96381). Otherwise, you will get the working directory empty. You can find the revision number in viewvc like this:
      Index of /ProjectA
      
      Files shown: 0
      Directory revision: 96365 (of 96381)
      Sticky Revision:    
      
  • Apply git patch to SVN:
    git diff --no-prefix > /tmp/xx.patch
    cd svn-dir/
    patch -p0 < /tmp/xx.patch
    

No comments:

Post a Comment