I cloned an existing svn repo off a remote server locally using git-svn’s git svn clone <orig_svn_repo_path>. I now want to setup a remote repo for only a particular branch out of several branches of the locally cloned repo say <cloned_repo>/branches/<branch_to_clone>. Is this possible to do? The rest of the repo is pretty humongous in terms of size and as there is only that particular branch that I have to work on, I’d rather just setup a remote mirror for it. Also if that is possible, how would I then update the original svn repo with the branch being worked upon and also push my changes to the remote git branch (repo) to keep it in sync with the local branch (that is updated onto the svn repo) ?
I cloned an existing svn repo off a remote server locally using git-svn’s git
Share
If you want to make commits to SVN (using
git svn dcommit), you should not use agit cloneof any git repository.You should instead use a
git svn initcommand with the appropriate parameters so that only the SVN directory you’re interested in is fetched, and then agit svn fetch. You can do this as many times as you like.If you do a
git cloneof a repository which is set up to track SVN, you have an issue: git-svn modifies the body of commits it sends to Subversion viadcommit, adding in agit-svn-idline. This is a type of history rewriting. So if you have a SVN-oblivious repository which pushes to the SVN-aware one, which then pushes to Subversion itself, you’re going to have an issue when you try to do agit pushthe second time.Just to make sure we’re clear, the problem is that the first repository will rewrite history when it does a
dcommit. So any new changes pulled down to another git repo from that point on will have a different commit hash, requiring forced pulls/pushes. It’s exactly like what would happen if someone were to rebase publicly-visible changes: see this SO answer.Fundamentally, git-svn is designed to be used with the SVN repository itself serving as the “central” repo.
If you want a read-only copy of Subversion, never doing another
dcommit(or at least not keeping the second git repo up to date after you do adcommitfrom the first), then you’re fine. Just do agit clonewith a refspec restricted to the branch in which you’re interested.