Skip to content

Instantly share code, notes, and snippets.

@technoglot
Last active April 30, 2019 16:18
Show Gist options
  • Save technoglot/e355f2f81d68a42ec658ab33668cab5d to your computer and use it in GitHub Desktop.
Save technoglot/e355f2f81d68a42ec658ab33668cab5d to your computer and use it in GitHub Desktop.
Git Commands Cheat Sheet
Git Command Description
git init Initializes a git repository within the current directory/folder
touch Creates a new file within the current directory/folder
code . Opens files in Visual Studio Code
git status Checks the status of all staged files. Changes can be tracked or untracked
git add Adds a single file to the staging area
git add . Adds all files to the staging area
git rm --cached
ls Lists the contents of the current directory/folder
git commit -m Commits all files in the staging area, with a short descriptive message describing the commit
git log Shows commit history
git log --oneline Summarizes commit history
git checkout
git checkout master Takes you back to the master branch
git revert Reverts back to a point in time, given the unique commit ID
VIM: shift+: --> wq
git reset --hard Hard resets a commit, given it's unique ID
git branch Creates a new branch
git branch -a Displays all branches
git branch -d
git branch -D
git checkout -b Creates a new branch and takes you there
git merge Merges a certain branch with the master branch. Make sure you are in the master branch at the time you merge.
git commit Only used after fixing a conflict
git clone Clones a remote repository, using the URL to that repository
git remote add origin
git push origin master Pushes to the master branch on the remote location
git pull origin master Pulls from the master branch on the remote location
git fetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment