A simple cheat sheet for Git commands.
git init
Initialize a new git repository.
git add filename
Add files to the staging area.
git commit
Record a snapshot of the history.
git commit -m “Your commit message”
Add a message for the commit from the command line.
git branch
Show all branches.
git branch branch_name
Create a new branch.
git checkout branch_name
Switch to a specified branch.
git branch -d branch_name
Delete a branch.
git merge branch_to_merge
Merges a branch into the current checked out branch.
git remote
View remotes.
git remote add name url
Add a new remote repository.
git log
View a history of commits.
git clone url
Grab a full copy of a repository that you don’t already have.
git pull
Grabs the local or remote branch of the repository that you are working on and merges it.
git fetch remote_name
This will update your local branch from a remote branch.
git push remote branch
Pushes local changes to the remote.