Tuesday 18 October 2011

Git - Track remote branch from existing local branch

Issuing the Git Clone command (git clone remote-branch local-branch) will get a latest version of the remote branch and update the local-branch config file to track the remote-branch.

How about if the local-branch exists already and all you want to do is tell git to start tracking the remote-branch from the local-branch without overidding all changes in the local-branch?

Try the following command;

git branch --set-upstream local-branch origin/remote-branch

To update your local set up with all available remote branches for a particular remote repository, try

git remote update
git branch -a
git checkout "branchname"

You can create a new remote branch from a local branch by simply issuing a push to the remote repository and specifying the new branch name like so

git push -u origin "new branch name"

Wednesday 12 October 2011

Versioning Visual Studio 2010 Solution using Nant

Creating an automated versioning functionality for a particular project may be straight forward, but often you’d want all projects in the solution to share the same version number without having to author each project’s “Assembly.cs”. If update fails for any of the projects, the solution will be left in an inconsistent state version-wise.

The solution to this is to create a common assembly file and link it to each project in the solution. Then any update to the parent common assembly will ripple through to all projects.

  • Create a solution folder and add an assembly file, namely “CommonAssembly.cs”.


  • For each project add the “CommonAssembly.cs” file AS A LINK, by right-clicking the project, Add, Existing Item.


  • Note the icon on the newly added file link.



  • Now add a Nant target to update the “CommonAssembly.cs” parent file at build time.