How to switch branch in git

If you’re fairly new to git and you’ve found this post, you probably know how to clone a git repo, and now you’re wondering how to switch branches. When you clone the repo you’ll generally start out on the main/master branch, and now you want to change to a feature branch before you start coding. … Read more

Categories Git

How to resolve merge conflicts in git

Recently I’ve been working on a project that uses Azure DevOps as the remote repo, but Azure DevOps does not include any way to resolve merge conflicts in Git remotely. What you can do is deal with the merge conflicts locally so I’ll include the instructions as to how to do that here, and this … Read more

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

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 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