Skip to content

Instantly share code, notes, and snippets.

@technoglot
Last active April 30, 2019 16:18
Show Gist options
  • Select an option

  • Save technoglot/e355f2f81d68a42ec658ab33668cab5d to your computer and use it in GitHub Desktop.

Select an option

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 <filename> |	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 <filename> | Adds a single file to the staging area
git add .	| Adds all files to the staging area
git rm --cached <filename> |	
ls	| Lists the contents of the current directory/folder
git commit -m <descriptive msg>	| 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 <commitID>	|
git checkout master	| Takes you back to the master branch
git revert <commitID>	| Reverts back to a point in time, given the unique commit ID
VIM: shift+:  --> wq	| 
git reset <commitID> --hard	| Hard resets a commit, given it's unique ID
git branch <branchname> |	Creates a new branch
git branch -a | Displays all branches
git branch -d <branchname>	|
git branch -D <branchname>	|
git checkout -b <branchname>  |	Creates a new branch and takes you there
git merge <branchname> 	| 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 <reposURL>	| Clones a remote repository, using the URL to that repository
git remote add <reposURL> 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