Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I track local-only changes/change sets with git-svn?

Tags:

git

svn

git-svn

I want to have files that I track in my local git repository that do not get checked in to the central svn repository when I run git-svn dcommit. I often have long-lived local-only changes to files tracked in the repository. Sometimes it's for debugging code. I also have project IDE files that I'd like to track. With plain old svn, I would just put those files into a changelist labelled "XYZ: DO NOT CHECK IN," and then just manually deal with the problem when I actually DO have changes that I need to commit.

Ideally, I would like to check my changes into my master branch but set something that prevents those specific changes from propagating to the svn repo. I would use git and git-svn in the conventional way, but certain commits never get pushed up. Obviously, I can do this manually every time I make a commit, but that's a pain.

I've considered and discarded a couple of things. I don't want to exclude these files, because sometimes I need to make changes that DO get dcommitted. Also, I'd like these files to appear in any local-only branches I create, like in the case of IDE files. However, I can't isolate these changes to a single branch because I will want them in every branch, as with the IDE files. It looks like something like guilt or stgit may do what I want, but it's not obvious, as they add their own layer of complexity on top of git, which I'm still learning.

like image 700
normal Avatar asked Mar 11 '09 20:03

normal


2 Answers

I am somewhat new to git, but I would recommend using a separate master and working branch in your local git repo.

Add your "non-SVN" files into the working branch only. Generally make all code changes in the working branch. When the "non-SVN" files change, add those using a unique commit, and set a commit message prefix (ie "local:" or "private:"). When you are ready to commit to SVN then:

  1. Show a log of commits to add to SVN:

    git co working
    git cherry master
    
  2. Add all upstream commits to the master branch, ignoring "private" commits. Repeat this step until all upstream commits are in master.

    git co master
    git cherry-pick <SHA1>
    
  3. Push commits to SVN repo:

    git svn rebase
    git svn dcommit
    
like image 190
cmcginty Avatar answered Sep 19 '22 14:09

cmcginty


My current solution to the problem is to use stacked git (stg) and maintain these local changes as separate patches. When I need to dcommit into Subversion, I do a

stg pop # naming the patches that should not be commited
stg commit # the rest of the patches to commit
git svn dcommit
stg push # naming the patches that are used locally

The nice thing about maintaining these as separate patches is that I can easily have patches that modify my unit tests to test different database backends. So normally I test against Oracle, but if I want to check against Derby, I do

stg push local-mods-derby
ant tests
stg pop

or if I want to test against PostgreSQL, I run

stg push local-mods-test-postgresql
ant tests
stg pop

Here, "local-mods-derby" and "local-mods-test-postgresql" are the patch names.

So maintaining separate patches of work is very easy with stg.

like image 24
Blair Zajac Avatar answered Sep 21 '22 14:09

Blair Zajac