Member-only story

Fundamental Git Commands + Traps To Avoid

Alex Chiou
6 min readDec 15, 2019

--

So powerful, yet so easy to mess up

In this article, I’m just going to go over all the Git commands I use on a day to day basis, split up by concept and use-case. I will also cover a lot of pitfalls junior Git users fall into and how to avoid them. I have noticed that the Git education in a lot of universities (my alma mater included) is quite poor, so I have seen a lot of messy Git usage across my career. So let’s jump into how you can use Git more cleanly and keep your team happy.

Pushing Code Changes

Status
Git is constantly tracking what’s going on as you make changes locally. To figure out what it sees, you do:

git status

This command is very important, because what it says will affect what you do with your next 2 commands, add and commit. This status represents the changed files Git detects across your project.

Diff
This tells you exactly what code changes Git is currently aware of and what the commit will look like after you add/commit whatever. Here’s how you do it:

git diff FILE_PATH

This will give you the lines added/deleted for that one file. If the diff doesn’t match your expectations, you’re going to want to hit save in whatever IDE/text editor you’re using. You can also just do a…

--

--

Alex Chiou
Alex Chiou

Written by Alex Chiou

Empowering thousands of engineers @ Tech Career Growth. Ex-Robinhood, Facebook, Course Hero, PayPal. Built apps with 2.5 million+ installs for fun.

Responses (1)