Initialise new repository and push

Change to the project directory. Ensure .gitignore file has been created in directory and initialise git repository.

git init
git add .
git commit -m "Bootstrap project"

Create new repository in GitHub and push

git remote add origin
git push -u origin master

Simple clone, add, commit and push


git clone [email protected]:ianhomer/ianhomer.git
git clone


git status

Add all, new and modified or modified and delete.

git add -A
git add .
git add -u

Commit changes

git commit


git push


git pull

Prune branches

Remove non-existent remote branches from local

git remote prune origin   

List local branches ordered by date last modified => help deleting redundant branches

git branch --sort=committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

Credentials Helper

The credentials helper can help reduce password re-entry for HTTPS URLs. Note that For SSH URLs a SSH key is used to authenticate. Enable the credentials helper on OSX with - see Caching your GitHub password in Git for other systems.

git config --global credential.helper osxkeychain

Create a downstream only fork.

This pattern is useful for small prototypes and learning exercises based on base line project with no intention to push changes back upstream. Create "my-exercise" repository in GitHub web interface

git clone my-exercise
cd my-exercise
git remote set-url origin
git push -u origin master

Add upstream repository and disable upstream pushes
git remote add upstream git remote set-url --push upstream DISABLE git remote -v

To sync the fork, you can fetch upstream changes and merge into local master

git fetch upstream
git checkout master
git merge upstream/master