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?
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 svncreated a specialgit-svnbranch which contains the latest subversion code once fetched.The commands to update your files, followed by a git repo history update:
The last
git reset --mixedcommand 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 withgit commit(remove commit messages, not the changes). As a solution for that, commit viasvn commitand fetch your history as shown above.git reset --mixed git-svnsomehow unables you to commit to usedcommit. After runninggit reset --mixed git-svn, follow the following sequence to commit using git: