Introduction to GIT

Distributed version control

Session mechanics

  • Skype session with recording. Please mute your mics.
  • Questions can be asked during the presentation in the companion Slack channel:
  • Links to resources will be provided both at the end of the presentation and in the slack channel for further reading and future reference.

Who am I?

Jørn Ølmheim, GBS IT Drilling, Well and Realtime Services

  • Close to 20 years experience
  • Software craftsman
  • Polyglot programmer
  • Leading Advisor, Corporate IT


Introduction to Git

History

  • Initially written by Linus Thorvalds in 2005
  • Some of the goals of the new system was:
    • Speed
    • Simple Design
    • Strong support for non-linear development (branching)
    • Fully distributed
    • Able to handle large projects like the Linux kernel efficiently

Good practices

Merge Before New Changes

Commit Related Changes

Commit Often

Don't Commit Half-Done Work

Test Before You Commit

Use Branches

Agree on a Workflow

Common commands

  • git init: Initialize a new git repository.
  • git status: Shows the status of the local workspace.
  • git add: Add changes to the index.
  • git commit -m: Commit local changes.
  • git clone: Make a local copy of a git repository.
  • git pull: Pull changes from remote repository.
  • git push: Push changes to remote repository.

Other useful commands

  • git fetch: Fetch changes from remote repository.
  • git diff: View the differences between workspace and index.
  • git checkout [-b]: Switches to a new branch or creates a branch (-b).
  • git rm: Remove file from workspace and index.
  • git mv: Move file in the workspace and index.
  • git reset [--hard]: Reset local workspace and repository to match the remote.
  • git add -p: Cherry pick changes to add.

Demo

Distributed version control

Centralized version control

Distributed version control

Git explained

Git cheat sheet

Git deployment

Heroku

Digital Ocean

Resources and further reading