git

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 user.name "Gonzo von Space"
  git config --local user.email gonzon.v.space@gmail.com

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




Files.

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

.gitignore
  Ignore all .* but not .gitignore itself.
    .*
    !.gitignore




GitHub quick ref.

Setup
  git remote set-url origin https://github.com/patrick-sears/sandytest.git
  git push origin master
  git clone origin https://github.com/patrick-sears/sandytest.git