Git Basics

TotT: 2014

DVCS

"a distributed version control system ... keeps track of software revisions and allows many developers to work on a given project without requiring that they maintain a connection to a common network."
- Wikipedia

Use Cases

  • Keep backups
  • Revert to old versions
  • Track incremental changes
  • Merge concurrent changes
  • Explore alternatives safely
  • Encourage collaboration

Git

"Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."
- git-scm.com

Git by the Lingo

Git is a command line tool, git.

Really, it's a set of tools.

Git repositories track files and their changes over time.

i.e., files and their history

You edit the files in a working copy of a repository.

i.e., a directory of files and subdirectories

You stage working copy changes for tracking.

e.g., code for features, not debugging

You commit staged changes to the history.

e.g., when unit tests pass, when code is stable

Your repository may have many histories, or branches.

e.g., for stable code, for feature dev, for experimentation

You may merge branches at will.

e.g., to merge a feature branch into the master branch

You may pull commits into your repository from other repositories.

e.g., to get code from a colleague

You may push commits from your repository to other repositories.

e.g., to deliver a feature

Sometimes, you must resolve conflicts when merging.

e.g., when you and another dev commit changes to the same line

Demo: Personal, Single Branch Workflow

init, add, checkout, status, commit, log

Demo: Personal, Single Branch Workflow

Demo: Personal, Multi-Branch Workflow

checkout, branch, merge

Demo: Personal, Multi-Branch Workflow

Review

  • DVCS
  • Git
  • Personal Workflows