Member-only story
Git Commands to Live By
The cheat sheet that goes beyond Git basics

For some time now, I’ve taken it upon myself to write down every Git command I’ve had to look up while working from the command line. Whenever I did so, I’d note the proper syntax, most common options, and where I got the information from. Over time, and as my list grew, I came to rely less on Google and more on my list for quick reference.
Typical use cases (think vanilla git add
or git commit
) won’t feature here but rather a selection of less recurring yet nevertheless essential ones.
Note: The linked resources will often mention slightly different, often more concise versions of the commands listed here for newer versions of Git. So if you want the latest and greatest, be sure to give them a look.
Overview
1. Check Out Remote Branches
2. Delete Remote Branches
3. Change Remote URL
4. Stash Individual Files
5. Show Content of Most Recent Stash
6. Apply a Stash Without Deleting It From the Stash List
7. Check Out File From Another Branch
8. Work With Multiple Branches Simultaneously
9. Show Commit Content
10. Compare Files Between Branches/Commits
11. Reset a Single File to Most Recent Commit
12. Change Last Commit Message
13. Change a Specific Commit Message
14. Delete Last Commit but Keep the Changes
15. Unstage a File
16. Remove Ignored Files From Remote
17. Create GitHub Releases
A quick note on syntax
[]
: Optional content<>
: Should be replaced by the actual value when running the command
Check Out Remote Branches
We’re probably all familiar with git pull
to bring our local branches up to speed with their remote counterparts. However, if this is our first time working with the remote branch — i.e., it isn’t being tracked by any branch in our local repository — we first need to set that up.
Note: It’s a good idea to run git fetch
to make sure we’re working with the most up to date version of remote
.
- Command:
git checkout [-b <new-local-branch-name>] -t <remote>/<branch>
- Example:
git checkout -t origin/my-awesome-feature
- Explanation: This will…