Set global username and email:
git config --global user.name "Ben Wells"
git config --global user.email "b.v.wells@gmail.com"
Create repo:
git init repo-name
Clone repo:
git clone repo-url
Check status of changes:
git status
Stage file:
git add filename
Commit staged changes:
git commit -m "commit message"
Amend to last commit:
git commit --amend
Amend author in last commit:
git commit --amend --author="Ben Wells <b.v.wells@gmail.com>"
Re-sync origin to master:
git checkout -B master origin/master
Make file executable:
git update-index --chmod=+x foo.sh
Rebase commits:
git rebase -i HEAD~n
Rebase to first commit:
git rebase -i --root master
Delete all branches apart from master
git branch | grep -v "master" | xargs git branch -D
List current remotes.
git remote -v
Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Fetch upstream remote branches and commits.
git fetch upstream
Rebase upstream/master commits into local master.
git rebase upstream/master