Friday, 11 January 2019

The importance of the .gitignore file

A few days ago I spent a some time reviewing some old repositories of mine (mostly demos) and I realised how cluttered they were.

You know why? Because they were created years ago, went unmaintained for ages and they were lacking a .gitignore file.

Early in the days of learning Git, one of the things I left behind was - guess what - a proper usage of .gitignore files. Moving on I realised how important they are: they prevent your repository from becoming filled with temporary files you don't really need. If you go back to old repos you created when you were not as proficient as you are today, you are guaranteed to stumble into that like I did.

For example: if you create an empty MVP Application using ASP.NET Core and you run a git add --all you will surely add files like sqlite's db.lock file, which is utterly useless in a Version Control System.

Or the whole .vs folder, .suo files, the obj folders and so don't need this stuff in a Git repository!

At the end of the day a .gitignore file is literally a list of files to ignore in order to maintain your repository lean and nimble. Spend five minutes (tops!) on it, and you will get the rewards way down the line.

If you are *that* lazy and you think you can't spend five minutes on it, there is a nice service (what isn't commoditised today?!) called that will create a default one for you based off your favourite IDE or environment.

Really, do it! 😁

No comments:

Post a Comment