Newbie Git Cheatsheet
Here are a couple of git commands for you new gits 😉
Branches
Create new branch
git branch NewBranchName
Checkout to newly created branch
git checkout NewBranchName
Create new branch AND checkout to it
git checkout -b NewBranchName
Adding Changes
Add single file
git add fileName.txt
Add multiple files individually
git add fileName1.txt fileName2.php
Add all files
git add .
Commiting changes
First initial commit
git commit -m "We have just commited something"
Amending the initial commit
git commit --amend
Amending the initial commit with a new message
git commit --amend -m "We have amended our last commit"
Stashing things
Stashing your work
git stash
Un-stashing your work
git stash pop
Word of warning: Stashing is not local to your branch, but global to your project, so be careful!
Undoing things
Unmodifying a modified file
git checkout -- fileName.txt
Word of warning: you can’t reverse this command, so double check the files before you discard your changes!