I know the situation, working with an SVN repository myself via git-svn with some co-workers.
You basically have two options:
The easy way is to ONLY share code via SVN. This is the easy solution, because you'd use Git only as a sophisticates SVN-client with powerful local abilities. The only word of warning here is: NEVER EVER EVER EVER rebase a commit that already went into SVN! Or use a rebase-equivalent operation. Git-svn uses git-rebase internally to sync the changes that went into SVN without your local copy noticing and has to reorder your local commits.
If you decide that it is a good idea to also share code via Git, without involving SVN, things get way more complicated.
First of all, you should start with cloning a repository from SVN. This repository should be the master for everyone, and it should contain both the remote SVN branches, as well as local tracking branches for every branch in SVN that you might need. You'd be able to create them later as well, if you need them.
To get the repository to a new machine, copy the whole repo directory, including the .git
directory, to the new machine.
To share code, create a remote Git repo somewhere and add this as a new remote in every local repo. You can then push.
Be careful NOT to push the branches that track SVN! Your world of code sharing now is separated into two kind of branches: Either the branch is Git-only. Then you can push it to any other Git repo you want. OR the branch is tracking an SVN branch. Then you MUST NOT push it anywhere for sharing code.
With Git-only branches, the usual rules for Git apply: Be careful when rebasing anything that got pushed (i.e. don't rebase!).
With SVN branches, things are different. My own workflow is like this:
git checkout master
git add stuff
git commit
git push // regular GIT workflow until here...
git checkout svntrunk // name of the local branch tracking SVN trunk
git svn fetch // get all updates from SVN in any branch
git svn rebase // update trunk in local svntrunk tracking branch
git merge master --no-ff // merge local master to SVN - fast-forward is not allowed
// because SVN has no way of be alike - your changes have
// to be a regular commit in the SVN branch
git svn dcommit // move that commit into SVN repo
git svn tag v0.0.1-alpha // optional, but tagging in SVN only works after dcommit
git checkout master // back to work
Updating a branch that is related to an SVN branch uses rebase operations. So applying the usual Git rules about pushing a rebased branch, it becomes clear that this will not work! So don't push SVN tracking branches. Don't pull them. Only have them local and update them from SVN.
This two-branch workflow is not very nice. It allows you to share code via Git with your co-workers, but it doubles every branch that has to be in the SVN repository. And depending on how many people do the merging, the svn tracking branches will contain many commits that are actually their merge commits, but your local Git repo will not recognize them as merges. So the SVN branch in your local Git repo only knows about YOUR merges.
The situation will get worse if some of your co-workers use SVN directly, without Git. That way, you'd also have to merge back the changes in svntrunk
to master
. I have no experience with this, but I would say that in this situation it is best to avoid sharing code via Git, and remain in the single git-svn repo situation. Otherwise it will get VERY messy.