Let Git ignore modifications to a file

Introduction

Lately, at Codit.eu Belgium, we have been working on an internal project after hours and during a hack day. The project and the technology allow some of us, myself included, to get out of our shell and gives us a chance to work with technology we are unfamiliar with.

It is a really interesting work environment and this has sparked my interest in some of the things I haven’t had a chance yet to become familiar with. One of those things was Git. I have experience using TFS (Team Foundation Server) on-premise and VSTS (Visual Studio Team Services), in the cloud.

While setting up VSTS, one is give the option to choose for TFVC (Team Foundation Version Control) or Git. Until now, the safe choice had always been TFVC. This project finally let me work with Git and I must say I learned a lot from this!

2-comparison

This post is not an overview on what the differences between the two are (you can find that here), but rather a difficulty I had during development.

Don’t check-in credentials in web.config

The setup and baseline of the projects were in .NET and were done by a colleague of mine familiar with it already. One of the things I encountered was the fact that we worked with Azure DocumentDb and we need to store the DocumentDb URI and key in the web.config file. However, we can’t have them in the file itself as this is in no way secure.

However, when committing or pushing changes in my local branch to the remote server, I always needed to restore the web.config in its original state. Afterwards, to test the local version again, I needed to include them again. A real problem, as this is quite cumbersome and easily forgotten.

Let Git ignore any local changes

I searched the web for a solution and after some testing I found the solution to my problem here, on StackOverflow.

git update-index --skip-worktree <file-name>

Enter the command in a git command prompt. To get one, go to Team Explorer, Changes, Actions and click Open Command Prompt.

git_cmd

The command will update your local git index and mark the file to skip during commits and to assume no changes were made, although you may actually have made them!

Perfect for our web.config which (almost) never changes!
Even more so, since this only marks your local index and the change is never propagated to the remote index! This means that every developer wanting to do so, will have to do it manually his-/herself.
This is not something that a new developer would need to know about immediately, which is a good thing!

However, whenever we need to make an actual change (one that needs to be merged in the master branch), we need to remove the credentials, make our changes and commit and push the changes remotely to create a PR (pull request).

To do so, use this command in another Git command prompt:

git update-index --no-skip-worktree <file>

Hope you enjoyed this, as this made my life a lot easier on this project!

BTUG.be slide deck – Integrate 2016 recap

Yesterday I had a great time at btug.be, while presenting my session on Integrate 2016.

I presented the new changes in BizTalk Server 2016 CTP2, covered the upcoming changes in RTM and the new schema update of Azure Logic Apps, together with the new features available in the public preview of the Enterprise Integration Pack

Thanks again to our company, Codit.eu, for providing me the opportunity to be there!

As promised there, please find my slide deck below via SlideShare:

Contact me if you have any questions regarding the slides, I’d be happy to answer you.

The second speaker yesterday was Eldert Grootenboer. He had a great talk on IoT, gateways, sensors and … boats! Keep an eye out on his blog, since he promised some more IoT posts coming up.

As always, it was nice to talk to the people present. A big thank you to them! Especially since it was not such a great time to attend, just before holiday period and there were a lot of traffic jams around Antwerp yesterday evening. We do have a good community out there!

Enjoy the slide deck!

Pieter