Connor Finnegan
Jun 3 · 4 min read

As I’ve been learning to program, Git has mostly been a means to an end. For the uninitiated, Git is a version control system used by developers to improve workflow.

There are a core group of commands I use to organize, track, save, and publish my work, but I’ve always known there’s much more that Git has to offer. I thought it would be nice to take a closer look at some of the commands beyond git add, git commit, git push, and git pull, and I will go over some of the most interesting ones I came across in this blog post.

git diff

You may be familiar with git status, which shows you any files in your work that contain changes you made locally that have not yet been staged for commit. For example:

This shows me that my main.css file contains changes that have not yet been staged for commit. However, let’s say I ran git status and saw the name of a large file that I didn’t remember altering, and I didn’t feel like combing through the file to find the change. With git diff, I can see the actual changes that were made, like in the example below:

There are plenty of cases where this would be more detail than is necessary and git status will suffice, but I was excited to find out this extra level of detail is available as an option.

git stash

I’ve usually found myself on either of extreme of “I want to keep all of these changes” or “thank god I’m on a separate branch because I need to scrap all of this,” but there’s a very helpful option that splits the difference in the form of git stash.

Let’s say you make some changes that cause you to realize there’s a more urgent bug to fix, and you want to address that with a clean slate but don’t want to part with the changes you’ve made. This is where git stash comes into play. Running the command will take all the changes you have in your current tree that have not been staged for commit, and will save them somewhere else and give you a clean working tree again. Then, when you’re ready to look at them again, you can run git stash apply and put the changes back into your code.

If you anticipate that you might have trouble merging the work you want to stash with the work you’re about to do on the clean tree, you can create a new branch with git stash branch <new branchname>.

git grep

git grep essentially lets you search your entire codebase for a phrase from the command line, and then it will print the lines that contain the phrase and highlight which files contain it. Here’s what it looks like in action:

I had been unfamiliar with this command due to the global search feature in Atom, but it’s helpful to know there’s a way to perform such a search directly from the command line.


The Startup

Medium's largest active publication, followed by +504K people. Follow to join our community.

Connor Finnegan

Written by

Full-Stack Web Developer. Studied at @FlatironSchool

The Startup

Medium's largest active publication, followed by +504K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade