Git - Part 9: Remote repository on GitHub

1. When logged in to GitHub, click green button "New repository"

2. Choose repository name, enter description and click "Create repository"

3. Now you have two options: create a new repository on the command line or push an existing repository on the command line

New repository on the command line

Use this option, if you doesn't have an existing local repository initialized.

echo "# Some text" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:username/repository.git
git push -u origin master

Push an existing repository from the command line

Use this option, if you already have an existing local repository initialized and you want to push it to GitHub.

git remote add origin git@github.com:username/repository.git
git push -u origin master

Cloning remote repositories

Clone remote repository to a specific folder

git clone git@github.com:username/repository.git someFolderPath

Clone remote repository to a folder with the same name as repository

git clone git@github.com:username/repository.git someDirectoryPath

Remote branching

Checkout (or create) some local branch

git checkout feature-branch

Push branch to a remote repository

git push origin feature-branch

Delete remote branch

git push origin :feature-branch

OR

git push origin --delete feature-branch