Skip to content

Instantly share code, notes, and snippets.

@brianpeiris
Created January 5, 2013 17:26
Show Gist options
  • Save brianpeiris/4462613 to your computer and use it in GitHub Desktop.
Save brianpeiris/4462613 to your computer and use it in GitHub Desktop.
Git/GitHub Cheatsheet

Git/GitHub cheat sheet

Setup and Usage

Install git

sudo apt-get install git

Set the default name and email for git to use when you commit

git config --global user.name "Your Name Here"
git config --global user.email "[email protected]"

Set git to cache credentials

git config --global credential.helper cache

Initialize new repo

git init
git add .
git commit -m 'initial commit'

Frequent operations

Add new files to staging area

git add .

Commit changes

git commit

Undo (delete) any staged changes

git reset --hard

Delete all unstaged changes

git clean -f

Using GitHub

Clone your fork of the repo into the current directory in terminal

git clone https://github.com/username/Spoon-Knife.git

Change the active directory in the prompt to the newly cloned "Spoon-Knife" directory

cd Spoon-Knife

Assign the original repo to a remote called "upstream"

git remote add upstream https://github.com/octocat/Spoon-Knife.git

Pull in changes not present in your local repository, without modifying your files

git fetch upstream

Merges any changes fetched into your working files

git merge upstream/master

Pushes commits to your remote repo stored on GitHub

git push origin master

Pull requests: https://help.github.com/articles/using-pull-requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment