Git Operations

New Computer

Setting global git config options:

git config --global "name"
git config --global "email"

Setting the git lola alias:

Add the following to ~/.gitconfig.

    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
    branch = auto
    diff = auto
    interactive = auto
    status = auto


Amend last commit with current changes:

git commit --amend --no-edit

Reset N commits:

# soft
git reset HEAD~N
# hard
git reset HEAD~1 --hard

Checkout Branch from GitHub Fork

git remote add coworker https://path/to/coworkers/repo.git
git fetch coworker
git checkout --track coworker/foo

# then in future
git checkout foo
git pull

From this answer on StackOverflow.