Help! Github is ignoring my .gitignore file!

It’s been a while since my last post, but now I’m fully emersed in learning .NET Core I’m sure I’ll start to post more regularly again. For my first trick, an aides-memoires on getting the .gitignore file to work. Here goes…

I normally use GitHub (or other git-based systems) as my source code repository when writing code in Visual Studio. I really like the fact that I can use the .gitignore file to prevent all the chaff that Visual Studio creates from being sent to the repository. For example, the ‘bin’ and ‘obj’ directories, and all the temporary solution files Visual Studio creates that have no business being in a source code reposity. A good rule of thumb is not to allow any generated files to be commited. They can be re-generated at any point so committing them just bloats commits and slows things down.

However, I often find that if I make changes to the .gitignore file in an established project these changes are not honoured in subsequent commits. Executing the the following commands in Git bash solves this:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"  

Now, back to my .NET Core learning…

Deleting a local branch using the GitHub command line

Although it’s taken me a while to get to this point, I have to say that I really like GitHub. Historically I’ve used either VSS, TFS or SVN for source control. Each has its quirks, but essentially they all work in a similar fashion. GitHub feels (and probably is) vastly different.

Not being a massive fan of using command lines for simple tasks I do everyday, I use GitExtensions to add a UI to GitHub. It allows me to do pretty much everything I can do using the GitHub command line, and integrates really well with Visual Studio. However, one of the things it won’t let me do is delete a local branch quickly, especially if I have a few such branches to delete. I tend to use the GitHub website to deleted remote branches.

So, here’s the command to delete a local branch:

git branch -d the_local_branch_name 

Correction: I’ve since realised that it is possible to delete a local branch using the UI, as shown in the following screenshot:

Deleting branches