Tag Archives: GIT

Git Alias for Resetting Web.config

In circumstances where the only thing that changes in the Web.config file is the connectionstrings element (my local machine v.s my collaborators’ machines), I found myself entering the following command before every commit:

git reset HEAD TheNameOfTheWebProject/Web.config

Well, I got sick of typing all that, so I decided to create a simple alias.

git config alias.rew 'reset HEAD TheNameOfTheWebProject/Web.config'

Now my workflow looks like this:

git add -u
git rew
git commit -m "Some message about changes"

Note, I did not make the alias global, as it only applies to the Web.config of that particular project.

A Branching Strategy Using Git

An index of the HomeLibrary application posts can be found here.

Up until now, I have been performing commits against the master branch (and pushing to origin/master). But I recently came across this branching guide which made a lot of sense to me. You can download a pdf of the diagram here. As I am simulating a proper development process with the HomeLibrary application, I thought I should probably use some sensible branching principles.

So, my first (and only) step at this point was to create a development branch called develop and to commit my development work against that. I’ve also tagged the commit where the code branched as v0.1.0.0.. Had I been following this guide from the start, that tag would be my very first commit. Anyhow, I’m on track now with a branch/release management strategy. If I was to carve a snapshot out of that diagram, what I have done so far would be:
NewBranch

My next post will be a slice through the layers to display some simple data on a form; kind of a litmus test for my architecture so far.

GIT .ignore for Visual Studio Projects

Like many .NET devs, I have started using GIT for my source control. It is just so much better than Subversion, Mercurial and any of the other free products.

I have been honing my .gitignore file, to try and include every conceivable file that I should not be committing. So far, I have come up with this list:

Assemblies/*
*\build
*\release
*\Release
*\debug
*\Debug
*.suo
*.dep
*.aps
*.vbw
*.obj
*.ncb
*.plg
*.bsc
*.ilk
*.exp
*.sbr
*.opt
*.pdb
*.idb
*.pch
*.res
*.user
*\bin
*\Bin
*\obj
_ReSharper*
*.exe
*.csproj.user
*.resharper.user
*.cache
TestResult.xml
TestResults/*
Thumbs.db

I just drop this in the root directory of the project which GIT is monitoring, and Bob’s your aunty’s live-in lover!

To verify that your ignored file is doing its job, navigate to your repository and run the following command:

$ git ls-files . --ignored --exclude-standard --others

While I’m spouting git commands, run this one to list untracked files (i.e. not ignored and not even tracked):

$ git ls-files . --exclude-standard --others