1
votes

I am working on a project that uses SVN as repository which I use in combination with the Netbeans SVN plugin. I found Netbeans SVN diff lacking on showing several diffs below each other and therefore wanted to use git-svn for being able to use git gui.

The problem is now keeping both repositories in sync. My current workflow is:

  • Updating (with no local changes):

    svn up
    git stash -u # include new files too
    git svn rebase
    git stash drop
    
  • Comitting:

    git commit
    git commit ...
    git svn dcommit
    

These base cases do work, but it does not work nicely if I have local unstaged/uncomitted changes.

What is a better way to keep the local git-svn and .svn in sync?

1
This Git and Subversion chapter of the Pro Git book may help.Mightymuke
@Mightymuke Nope, it does not give me new insights or solve the problem.Lekensteyn

1 Answers

0
votes

I have found a workaround that works pretty well. The idea is to keep files updated using subversion and have git only update its history without touching any files in the working tree. git svn created a special git-svn branch which contains the latest subversion code once fetched.

The commands to update your files, followed by a git repo history update:

svn up
git svn fetch
git reset --mixed git-svn

The last git reset --mixed command is necessary to ensure that git knows that your files are from the last SVN revision. Note that this command will reset any commits you made with git commit (remove commit messages, not the changes). As a solution for that, commit via svn commit and fetch your history as shown above.

git reset --mixed git-svn somehow unables you to commit to use dcommit. After running git reset --mixed git-svn, follow the following sequence to commit using git:

git stash
git svn rebase
git stash pop
git commit ...
git svn dcommit