Delete local branches in git that don’t track a remote

The way our team manage git branches is to create a new feature branch at the remote end, then we do a git pull and switch to the new feature branch locally. Next we do our development work, commit and push those changes. Finally we merge the reviewed code into a central remote branch. All … Read more

.Net Core Visual Studio git ignore bin and obj folders

I’ve been building a .Net Core API recently and after getting the repo set up I realised there was a problem. The bin and obj folders had been pushed to the remote branch, so once our build was kicked off, it was failing. It transpires that there’s an issue with the Visual Studio git ignore … Read more

How to rename a git branch

What is git branch rename? Is that even a real git command? No it isn’t, but it is pretty easy to rename a git branch and this post will show you how. I’ll also have a detailed example of exactly how to rename your git master branch to main. Look at this screenshot of my … Read more

Git stash changes – how to stash changes

If you’ve just realised you’re working on the wrong branch and you’ve already made changes, then this post could be for you. Picture the scene, you’ve edited a few files you’re half way through building a shiny new feature and then it dawns on you that you *forgot to create a new feature branch* before … Read more

Git delete local branch – and how to delete the remote branch

If you follow a typical git workflow you will probably have been developing each feature, or fixing each bug, on it’s own branch, and then merging each branch into a central development branch in the remote repo. In this kind of scenario at the end of a project you may have many local branches that … Read more

How to change the display name in Git bash

I share screen shots quite a lot in my blog posts and got fed up of needing to blur the user name information from my Git bash terminal screenshots. So I edited the shell prompt text in order to customise Git bash. Here are the steps you need to take in order to edit the … Read more

How to revert a commit in git

git revert how to undo a commit

Git revert is the command you need to undo a commit in Git, and is the safest way to change history in a git repo. Rather than just discarding changes, like git reset, which I covered in this post, git revert looks at the changes made in a commit and then reverses, or applies the … Read more

git fetch vs pull

git fetch vs pull

Should I use git fetch or git pull? What does git fetch do exactly?! In this post I’ll clarify the difference between the two git commands – and to answer the git fetch vs pull question. In summary it’s a simple difference – git fetch ‘fetches’ all of the information about your git repo, so … Read more

What is git? Git explained in plain English – Part 2

Git explained in plain english

This is a follow up to my previous post ‘What is git? Explained in plain English‘. In that post I explain what git is, what a git repository is, what a branch is, and how to create a remote repo. In this post I’ll cover the following topics: how to use git commit to save … Read more

How to undo your last commit in git (or ‘git undo commit’!)

git undo commit

Have you ever accidentally committed something to your git repo, or realised after you’ve committed your changes that you’ve made a mistake? If so, this blog post is for you and it will teach you how to ‘git undo’ a commit. Git reset is what you need and I will walk through the steps of … Read more