How-to branch and patch SVN- or TFS/Codeplex-based open source projects with GIT (Part 1)

The last couple of weeks I worked a lot with NPanday which brings maven to .NET. But this post is not about NPanday but rather about the workflow for maintaining a personal branch and uploading patches.

I’m not a committer, but I had to do some changes to NPanday. I still want to version my changes. I also want to contribute patches, when I fix bugs that apply to the current trunk.

NPanday is hosted on Codeplex, and though accessible via the SvnBridge. So I chose to give git svn a try.

I also want to host my changes on github.

The Workflow

  • Once
    • Clone a svn repo to a local-git
    • Create a branch for svn updates, say codeplex
    • Create a GitHub repo and push both branches
  • Repeatedly
    • Do your work on master
    • Commit and push your work
    • Update codeplex from subversion and push it
    • Merge codeplex to master
  • Contribute and Commit
    • How to create and submit patches from our master
    • How to commit changes back to codeplex

The How-To

I don’t want to mess around with npanday, so I created a empty test-project on codeplex.: [SAMPLE PROJECT] Branch and Patch with GIT

Setup (Windows)

On mac you simply use mac ports, on linux I have no clue.

  • Install SVN binaries and add to %PATH% (download)

  • The binary mysys doesn’t come with git svn anymore, so you have to compile it yourself. Is not as hard as it sounds. Just download the fullinstall – it will run the compile for you. (download 1.7.0.2 , downloads) Don’t forget to add it to the path, too.

I’ll do everything on the command line. Red is SVN, green is GIT – they are in separate folders.

I use pictures. Type it yourself! It will help you to learn it.

Don’t be afraid reading the command line either. It’s like code! You’ll get used to it, so did I.

Once

Checkout and commit a text fileimage

Init and fetch the commited revision using svn git:

image

Now, since we want to do changes, lets create a branch codeplex but remain on master and do changes.

image 

We should make sure, that the branch codeplex is untouched:

image

I also created a project on github. So lets push it over there. Read how to setup your private key and connect here.

image

Now we have the two commits on the master:

tmp2E0B

And only one on codeplex:

tmpE826

Now we change our “subversion”-file:

image

And then we update it using git svn rebase on the codeplex branch. Sorry for not having accepted the certificate before. But its live! 🙂

image Result:

tmpD8EB

Now we want to have that change over on our work branch.

image

Voilá:

tmpF6A9

Now, this is our repo:

image

Enough for today. Let’s se what we covered:

Recap

  • Once
    • We initialized the empty codeplex repo with a single-line file.
    • Clone a svn repo to a local-git
      We used git svn init and fetch to get the codeplex contents in a local git repository.
    • Create a branch for svn updates, say codeplex
      We created the branch
    • Create a GitHub repo and push both branches
      We pushed both master and codeplex
  • Repeatedly
    • Do your work on master
      We added a file to our master.
    • Commit and push your work
      We pushed it to master. Both the source svn and codeplex branch remain untouched.
    • Update codeplex from subversion and push it
      We added a line and checked it into svn and then we got it into our codeplex branch did that.
    • Merge codeplex to master
      We did that too.

More soon! Probably next Friday:

  • Contribute and Commit
    • How to create and submit patches from our master
    • How to commit changes back to codeplex
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s