Monday, March 22, 2010

git svn usage notes

I've been using git-svn recently, and like it quite a bit. The killer feature for me is that I can make commits while off-line; I like being able to commit changes in small chunks. Here are some notes on how I most frequently use it.
  1. Start. Make local copy of trunk, branches, tags and revision history.
            $ cd ~/src/git
            $ git svn clone svn://myprj
            $ cd myproj/trunk
    
  2. Push your local changes to SVN repository.
            $ git svn dcommit
    
  3. Revert your local changes to last version you committed.
            $ pwd
            /home/mark/src/git/ao/trunk/wwwrpt
            $ git show HEAD:trunk/wwwrpt/Makefile
            $ git show HEAD:trunk/wwwrpt/Makefile > Makefile
    
  4. Revert to the version before your last commit.
            $ git show \
            > HEAD~1:branches/2.2_WORKFLOW/engine/session.h \
            >> engine/session.h
    
  5. Fix commit message on last commit. (Must do before dcommit.)
            $ git commit --ammend
            [spawns editor with prior comment: edit and save]