Member-only story
Start Using Git on the Command Line Like a Pro in Five Minutes
A quick tour of basic Git commands

You write code every day, right? Why not write Git commands like a code instead of clicking over to your GUI tool?
OK, you need some time to familiarize yourself, but once it happens, you’ll be more efficient than ever.
I’m going to show you some basic Git commands and their features. This isn’t another Git documentation, though.
Git Status
The git status
command shows what the full status is, where the HEAD
is, and what the changes are (staged, not staged, untracked files).
Once you’re familiar with the long output, you might use the git status --short
to see the minified result:

Manipulate the Changes
Here’s a list of some commands that allow you to manipulate the changes:
git add file
— adds thefile
file to the stage sectiongit restore file
— discards changes to thefile
git restore --staged file
— removes thefile
from the stage section
The file
may be replaced with any file or directory path you want to modify.
Inspecting the diffs
git diff
— displays the not-staged changes in your working treegit diff --staged
— displays the staged changesgit diff dev
— displays changes between the working tree and thedev
branch. You might use a commit hash or tag instead.git diff master..dev
— displays changes between the branchesmaster
anddev
You might pass a path to a file or directory as an additional argument to filter the diffs to a specified path.
If you only want to inspect the file names, use the --name-only
switch. If you need to know which files were modified, added, or deleted, use the--name-status
switch.