Buy @ Amazon

Search This Blog

November 9, 2010

Git-SVN bridge

This post should serve as a quick reference material for Git-ites (wannabes and me) who'll have to use svn as configuration management system for whatever reason it be. In such situations install git-svn onto your system so that you can have git as your local repository and pull from/push to remote svn that the team uses as central versioning system.

Remember that for all actions on your local repository use the regular git commands. The need for git-svn commands arises only when you need some information/artifacts from svn repository.

1. What is the command to update my local git repo with changes from the remote svn repo?
    git svn rebase

2. What is the command to commit my local changes to svn repository?
     git svn dcommit

3. What is the sequence of steps to push my local changes to svn repo?
     i. When you change existing or add new files, you need to add it to the local git repo
         git add <file_path>  or
         git add <directory_path>
     ii. Commit added files to local git repo
          git commit -m "<Commit Comment>"
     iii. Get latest updates from svn repo
          git svn rebase
     iv. Commit changes to svn repo
          git svn dcommit

4. What is the command to see log of commits?
    git svn log --limit=5 --verbose --show-commit
    where,
    --verbose or -v
        it’s not completely compatible with the --verbose output in svn log, but reasonably close.
    --revision=<n>[:<n>]  or -r
         is supported, non-numeric args are not: HEAD, NEXT, BASE, PREV, etc

[More to come...]


Recommended Books for Git:
Pro Git     Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development