Git Fundamentals

Git can seem overwhelming, but while performing typical day-to-day tasks, you'll use only about ten commands. If you happen to use Oh My ZSH, the included git plugin adds many aliases. Below each command, I've included the corresponding alias.

# Start a new branch for a new feature
git checkout -b new-feature
gcb new-feature
# Commit as you make changes (the --all adds changed files to
# `staging`)
git commit --all --message "your commit message"
gcam "your commit message"
# Add new or deleted files to `staging` (the `git commit
# --all` above only adds tracked files)
git add --all
# Check the status of your branch/commits
git status
# Switch branches
git checkout branch-name
gco branch-name
# Separate `git` plugin alias to switch back to master
# See what has changed (maybe done prior to committing, include
# the `--cached` flag to see what has changed in `staging`)
git diff
# Pull new changes down from remote (Github/GitLab/etc.)
git pull
# Push changes to remote
git push --set-upstream origin
# Merge changes from another branch into the current one
git merge other-branch-name
gm other-branch-name
# Or, if you prefer rebase,
git rebase -i other-branch-name
grbi other-branch-name

And that's it! 95% of the time, you'll use these commands. Google was invented for the remaining 5% 😉

Stay up to date

Get notified when I publish. Unsubscribe at any time.