Git Version Control

Presented by Tim Oram

Created in cooperation with the Computer Technology Society of NL

Why you should use a VCS?

What and why Git?

The basics of using Git?

What is version control system?

Software development workflow

Create

Edit

Save

Repeat

You may want to know...

Why you made a change?

When you made the change?

What changes were made?

...at any time in the future.

Multiple developers?

Who made the change?

Early Version Control

Tar ball CVS

You get the when, the what,

but not the why

and tarballs are difficult.

Multiple Developers

Tar ball CVS with multiple developers

You get the who,

but it is very messy

and which version is newer?

Tar ball mess

History of Git

Developed by Linus Torvalds in 2005

for the linux kernel because

the previous tool they used was no longer available

and everything else sucked.

Why did the others suck?

They were either slow, complicated

did not handle large projects well,

or were not distributed.

Why use Git?

Git is fast!

Has one of the best branching systems.

Fully distributed, no central server.

Local, no network connection required.

Centralized System

  • Commit to server
  • Pull from server
  • History saved on server
Subversion server based system

Centralized System

Server is required for most operations

Server connection lost?

No version control

Distributed System

Git based system

Distributed System

Every developer has their own copy

with their own history

to which they can push and pull to others.

Distributed System

Seems confusing, right?

GitHub can act like a central server

The main states

The main states

Repository

Staging area

Working directory

Repository

The .git directory

Where your history is stored

Where you commit files

Staging area

Where you construct your commit

Layer between you and the repository

Working directory

Current copy of the repository

Actual files and directories

What you use and modify

Basic workflow

Modify files in the working directory

Add files to the staging area

Commit the staging area to the repository

Checkout files from the repository to the working directory

Basic workflow

Git States

Git Basics

Getting a repository

git init

git int current directory

Initialize in the current directory

git int

or under the directory provided.

git clone <repository>

git clone

Clone in a remote repository.

Status checking

git status

git status

Shows the state of the repository

Staging area

git status

Modified files

git status

Untracked files

git status

Unmodified files

Files Git is tracking but have not been modified

Not shown by git status

Status workflow

git status

Tracking new files

git add

Add a single file

git add file

Recursively add folders

git add recursive

Combined

git add combined
git add status

Committing

git before commit status

A basic commit

git commit

git commit result

Deleting tracked files

Remove a single file

git remove

Remove a directory and all the files contained

git remove recursive

The status

git remove status

Unstaging

Remove file from stage

git reset head file

Remove folder from stage

git reset head recursive

The status

git reset status

Undoing changes

Checkout a single file

git checkout file

Check out a folder

git checkout recursive

Status

git checkout status

Teamwork

Remotes

Hosted on a network

You can have one or many

Collaborate with others by pushing and pulling data

Working with Remotes

Add a remote

git remote add

List remotes

git remote list

Remove remotes

git remote remove
git remote list

Push to a remote

git push

Pull from a remote

git pull