Search code examples
gitgit-rebasegit-cherry-pick

Manage a patched workspace in git without sharing the patches


I use git with SVN and I have a commit that I don't want to be pushed via dcommit but I need to do my local development.

The way I do it right now is

git checkout git-svn -B master
git cherry-pick ????..work
git svn dcommit
git checkout -B work
git cherry-pick mypatch^0

In the work branch, the commit after the git-svn tag has a commit containing mypatch after that is the work I actually do for the change set.

What I was wondering is whether it is possible to specify ???? as the second commit after git-svn on the work branch. That way I don't have to go through the log and find the revision myself.


Solution

  • Found the proper sequence. I needed to tag the new patch branch so I can refer to it symbolically.

    git checkout git-svn -B master
    git rebase --onto git-svn current-work-base work
    git svn dcommit
    git checkout -B work
    git cherry-pick mypatch^0
    git tag -f current-work-base
    

    The tag current-work-base must point to the patch that comes after git-svn

    This solution can work in a Windows batch file as well no need for bash. (just change ^ to ^^)

    Please note that when rebasing the work branch, the current-work-base tag needs to be updated again.