Command Line

This is a cheatsheet for Git beginners.

git init

git init creates a new local repository

$ git init
Initialized empty Git repository in /Users/a_user/projects/testproject/.git/

git clone path/to/repository

git clone creates a local repository from a remote repository

git checkout —

git checkout --<filename> replace file with latest version on HEAD

git add filename

git add <filename> stages files for a commit

git add .

git add . stages all files for a commit

git commit -m “message”

git commit -m commits files that have been staged

git commit -a

git commit -a commits all new files and have been changed since last commit

git push origin master

git push origin master pushes all commits to the remote repository with the master branch

git remove -v

git remove -v lists all the remote repositories currently configured on the local repository

$ git remote -v 
origin	git@github.com:awesomeuser/myproject.git (fetch)
origin	git@github.com:ausomeuser/myproject.git (push)