DEV Community


GIT Cheat Sheet Most Used Commands

Mobile and Web development
Originally published at Medium on ・2 min read

Hello there! I’ve been using GIT for 6 years now and there are commands that I just use much more than others. I did my own git cheat sheet with the commands I believe are the most used ones in the industry. Feel free to educate me if I am wrong! I will add up some more if it makes sense.
Here it goes:
git init — Create and initialize an empty git repo in a specified directory.
git clone — clones a git repo to a new directory.
git config — define user, email, create a shortcut command (alias)
git commit -m “” — commits the staged snapshot with a message associated.
git commit — amend — replaces the last commit.
git rebase — Rebase the current branch onto , base can be a branch, a commit ID
git reflog — Show a log of changes to the local repository’s HEAD.
git branch — lists all branches.
git branch — creates a new branch.
git checkout -b — Create and check out a new branch named
git merge — Merge into the current branch
git status — List which files are staged, unstaged, and untracked
git log — Display the entire commit history
git diff — Show unstaged changes between your index and working directory
git remote add — Create a new connection to a remote repo.
git fetch — Fetches a specific , from the repo. Leave off to fetch all remote refs
git pull — Fetch the specified remote’s copy of current branch and
immediately merge it into the local copy.
git push — Push the branch to , along with necessary commits and objects, creates the branch on the first push.
git revert — undoes all of the changes made in , then apply it to the current branch.
git reset — Remove from the staging area
git reset — hard — Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory
Let me know what you think! My favorite way of using git is a mix of the command line and the vs code! How about you?

Discussion (0)