Git intro workshop

Jiri Hubacek

We are going to…

  • Clone repository.
  • Explore that repository.
  • Create new repository.
  • Check repository current state.
    • Understand states of patches.
  • Build repository history.

Clone repository

From rtime gitweb clone the repository.

git clone ssh://git@rtime.felk.cvut.cz/hubacji1/oneflow.git

Explore repository

  • git log
  • git log --graph
  • git log --oneline
  • git log --decorate
  • git show COMMIT

Create new repository

  • git init
  • git config user.name "Your Name"
  • git config user.email you@example.com
  • git config --global user.name "Your Name"
  • git config --global user.email you@example.com

Check repository current state

  • git status
  • git diff
  • git diff --cached

States of patches

  • Patch is hunk of file change.
  • There are 3 states of patches:
    • untracked,
    • unstaged,
    • staged.
  • There are following transitions:
    • untracked, unstaged -> add -> staged;
    • staged -> reset -> untracked, unstaged;
    • staged -> commit -> git history.
  • Draw it!

Build repository history

  • git add -p FILE
  • git add FILE
  • git reset -p FILE
  • git reset FILE
  • git commit -m'COMMIT MSG'
  • git commit