yysun's space

Use Git as Local Repository

Posted on: December 21, 2009

I had a good impression about the Eclipse's Local History feature before, which allows me to view, compare and merge with my previously versions of the source code. Later on, I used an add-in for Visual Studio 2005/2008, called Visual Local History 2005. Now I started to use Git on my laptop. Suddenly I am able to do branching locally.

Branching used to be a scary thing that requires a lot of planning for server based source code management. E.g. In order to do a proper branching on Microsoft Team Foundation Server, we have to read, understand and follow a book, Team Foundation Server Branching Guidance. Git made it cheap and easy to do branching on local. This let us create as many as branches we want. Not only production and testing branches, but also experimental branches for features and try outs. I played it a little bit and here are some nice experiences.

One Repository and Switch Between Multiple Branchess

I created one repository for my solution which includes three projects to start with, a Silverlight class library, a Silverlight Application and a Web application to host Silverlight application. Then I created three branches, master, develop and tryout. In the tryout branch, I removed the web application project from the solution and made the Silverlight Application generate a test page instead.

Switching between develop and tryout branches (in terms of Git's terminology it is checkout), Visual Studio detects the solution file has been changed and will reload the solution file and source files accordingly. Git must be preparing/restoring files for the branches! No need to create workspaces and separated folders for branches! No need to mapping the working folders. One caveat though is that you cannot switch branch if there are pending commits.

Cherry-Picking and Mergee

I added all files before modifying the .gitignore file. The files in the bin and obj folders are included. To fix it, in tryout branch I deleted the two folders. Because I don't want to apply other changes back to the develop and master branches yet, I used the Git cherry-pick function to apply only the deletion back to the develop and master branches.  Nice and easy. But to do it from the master branch is even easier.

For some reason the .pdb files weren't deleted (maybe I had the Visual Studio in debugging). They are still under source control. This is even easier to deal with. I switched to the master branch. Deleted the bin and obj folder again. Commit and Merged the deletion into the develop and tryout branch..

Next I am going to install Git on a desktop computer and push code from laptop.

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


  • None
  • Pk: The horizontal view is a pleasure to use! Good thinking
  • randyburden: A valiant and commendable effort. Your use of Tuple is a little weird but it offers a feature that most other microORMs don't. Your use of a static Gu
  • reav: great work done on Rabbit Framework. just started to learning it, and by now i think it will solve all my problems and questions, that i had in webpag

Categories

%d bloggers like this: