Back to REF main.

Internal links.

Quick ref.

Get info.

  git show

  git config --list
  git config -l
  git config --list --system
  git config --list --global
  git config --list --local

  git --version
  git help 
  git  --help

  git status
  git branch -a
  git remote -v
  git remote show origin

  git log
  git log --oneline
  git log --stat
  git log --graph --oneline
  git log --oneline --merges
  git reflog

--merges:  show only merges

Setting configuration.
  git config --local "Gonzo von Space"
  git config --local

Create a new git repo in current dir and
add all files to it.
  git init
  git add .
  git commit -m "Initial commit."

Branching (example branch deva)
  git branch -a         # list all branches
  git branch deva
  git checkout deva

Given main.cpp that was changed and staged but
not committed yet, revert back to the way it
was before work started:
  git checkout main.cpp

Stuff to only do locally because it changes the commit hash.

Changing it after it's been pushed to a public repository will break the repository of anyone who has pulled the commits that are now gone. They are gone because changing a commit changes its hash and effectively creates a new different commit.

Change the commit message for last commit.
  git commit --amend -m "This is the new message."

Given changes that were made since the last commit.
Add those changes to the last commit:
  git commit --amend


Configuration files:
  system       /etc/gitconfig
  global       ~/.gitconfig
  local        ./.git/config
Where local "." is the working directory of the
current git repo.

  Ignore all .* but not .gitignore itself.

GitHub quick ref.

  git remote set-url origin
  git push origin master
  git clone origin