This is a follow-up to this previous question. So there you can find what I did so far.
In short, I created a new git
branch branching from a branch that is dcommit'ed to a remote svn
repository.
This new git
branch is intended to only be used locally and never to be synchronized with the svn
.
While I can ensure this manullay as explained in this answer, the new git
branch 'remembers' its svn
origin:
$ git svn info
Path: .
URL: [path-to-host]/[svn-repo]/trunk
Repository Root: [path-to-host]/[svn-repo]
Repository UUID: [repository-uuid]
Revision: [revision]
Node Kind: directory
Schedule: normal
Last Changed Author: sg-lecram
Last Changed Rev: [revision]
Last Changed Date: [date]
So assume if I checkout the new git
branch and commit some changes to the local git
, I could run git svn dcommit
sending the changes to the svn
. While I do not plan to do this, all it needs is to forget for a split-second on which branch I am on to publish all the secret changes in the secret git branch.
I would like to be able to unlink the new git
branch from the svn
so that trying to dcommit from that branch results in an error.
How can I do this?
You can't. git-svn finds the associated subversion repository by searching history for a commit message containing a git-svn-id: ...
line with a reference to a subversion commit recorded in git-svn's history. Once it arrives at commits from the subversion-tracking branch, it will find one.
I'd suggest to alias git
to a script that hooks into svn dcommit
, and checks whether you are in the correct branch before passing on to the real git
command. While this requires you to modify your system outside the repository, its also by far the simplest solution.
All technical options I can think of require you to prevent git-svn from reading too far into history:
git checkout --orphan
new_branch_name
, it will have a disjoint history and therefore not have any commit
messages with valid references to svn.With both solutions, merging your work branch back into its parent branch is more involved than usually. For the first option, branch again from your branch and then rebase -i
against master skipping the first commit, then pull to master. For the second one rebase
with --onto master
and upstream
set to the root commit of the branch.