Commit your local git branch changes first, then checkout another branch

One of the things people get confused about is the branching in Git, specifically, the local branching. If you make a local branch, make code changes and then commit those changes to the local branch, you are free to switch to another branch and Git will automagically manage your files for you.  From the git book:

Git resets your working directory to look like the snapshot of the commit that the branch you check out points to.

But it's very easy to make a mistake here.  If you don't commit the changes in your new branch and instead check out another branch, those changes will be there too.  I've seen this cause confusion with developers.  So if you make a local branch off your "develop" line:

git checkout -b NewBranch develop 

and make some changes to files, you have to commit those changes to "NewBranch" or you'll still see them  as modified files if you switch back to the "develop" or "master" branches. Now if you commit those changes to NewBranch line first, then checkout "develop," you won't see them as modified, and the files will instead be in their state from the "develop" branch.

Happy Local Branching!


ASP.Net Razor Syntax for using a variable in html or html attribute

Because I always forget how to do this, here's a quick note on the Razor syntax in an html variable.  For a integer variable named: imgWidth that has a value of 214 you can put it in an html attribute like this:

<div style="width: @(imgWidth)px;">

and it will render like this:

<div style="width: 214px;">

I know I know.  The css gurus will be lambasting me that I put inline styles in this example.  So sue me.  Sometimes inline styles are necessary.