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.


Whoever says Google has poor support is wrong

I use a few of the Google tools available.  When it comes time for my monthly backups of my web stuff, I use Google Takeout.  Google Takeout creates a backup of all your Google stuff and creates one big zip file of it that you can download to your machine.

I had some trouble with it today, it wasn't generating my download file so I sent an email to their support team.  I got an email back in about five minutes:

Hi Rich,

Thanks for your mail.  We're currently working on this issue, we hope to have it resolved by next week.  Sorry for the inconvenience,

--The Takeout team

So I'll try again next week and see if its working as expected.  But overall not bad support for what is essentially a suite of free tools.

UPDATE 11/30/2013:

Another Googler got back to me and said to try again, and sure enough it worked just fine.  Problem solved.  Thanks Google.  Now get back to keeping the NSA from spying on my appetizer recipes in Google Docs.


Visual Studio using old app.config value or setting

Once in a blue moon, I will run into a problem with Visual Studio 2012 where the App.config for a console application is getting cached somewhere and there's no way to release it.  So the App.config is stuck with old values which aren't correct for the application today.  It's happened maybe twice this year to me.

The App.config in my solution shows the correct values.  The one that's been put in the output directories for Debug and Release both look good, but my quick little console application is pulling ghost values from an App.config from last week. I've tried building, rebuilding, and finally, all to no avail.

The only thing I could think of to fix this ( which did work ) was:

  • Copying the contents of the App.config file from within Visual Studio
  • then delete the file from within Visual Studio
  • Then re-add the config file
  • Then paste in the contents.
  • Rebuild and run.
I'm going to chalk this one up to ghosts in the machine.