Git – How to track local-only changes/change sets with git-svn

gitgit-svnsvn

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.

Best Answer

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