Member-only story
8 Advanced Git Commands Universities Won’t Teach You
Advanced tips and tricks that will save you time and headaches.
When I started on my DevOps journey, I was blissfully unaware of everything ahead of me. Yet, after years of working closely with some highly talented developers, I begin to hit my stride. It’s incredible how much you can learn sitting next to a senior developer who gives you the time of day and has been there all before. Day in and day out, sponging knowledge from an expert in the field will teach you things you can’t find on any online course or university.
Whilst yes, courses, tutorials, and schooling will teach you core concepts. Today, I want to dive a little deeper and show off some of the handy tips and tricks I’ve picked up over the years. Using these advanced git commands, we can not only save precious hours every week; but gain a deeper understanding of the tool.
These commands are some I regularly use in every project I’ve worked on and have lived on my notes page for years. So without further adieu, I hope you enjoy my top eight advanced git commands

1. Searching in Git
If you’re looking for a code in your repository that might have been long since removed, git has your answer. Using the below command, we can search for any phrase throughout any commits or branches.
$ git rev-list --all | xargs git grep -F ‘’
For example, suppose you want to search for the string “clapfor=joelbelton;” in your repository:
$ git rev-list –all | xargs git grep -F ‘clapfor=joelbelton;’
C2011:bestdev.py: clapfor=joelbelton;
B9831:devops_technical_writter.json: clapfor=joelbelton;
2. Clean up your local branches
We can delete local branches that have already been removed from our remote repositories.
git config --global fetch.prune true
We can also delete any local branches that have been merged with our example:
git branch --merged master…