Do: Managing versions of program code with Git

Ben Holmes, IT Services
github.com/bdvholmes

Motivation

Playing spot the difference

Common indicators that something is going wrong:

File names have dates in

Files are called things like "old" or "latest"

Whole directories have multiple copies

One person can work at a time

Memory sticks / emails

Source control

Version control systems

Recording change by change

We want to know

  • What changed in which files
  • Who made the change
  • When the change was made

We might want to have

File locks

Branching

Merging

Tagging

A single, central source of truth

vs

Distributed structure
















Key facts

Free and open source

Cheap branching

Distributed

Flexible workflows

Great community

Voodoo magic

Basic concepts in Git

Commits

Lets start with an example

A message to the future

Example

Branches

Tags

Staging area

A basic git workflow

1. Pull changes

2. Make small code changes

3. Commit as you go

Write a message to describe the change you just made

4. Push your changes

Git will try to merge your code automatically

You may need to resolve conflicts

For bigger changes

Create a new branch before you start

Merge the branch back in when you are happy

Eventually you will be able to

Ammend your last commit

Ammend all of your commits

Rewrite history altogether

Make people cry

git push --force

More advanced workflows

Atlassian tutorials

Git tools and clients

The command line

Git gui

Github for mac

Integration

... and many more

GitHub

Git hosting

Free for public repositories

Live demo!!

Honorable mention

Bitbucket

Where to go from here

The Git website

http://git-scm.com/

Online Git tutorial

Command line Git in 15 minutes

http://try.github.io/levels/1/challenges/1


Atlassian do tutorials too...

GitHub

See the code for this talk, fix my typos

https://github.com/bdvholmes/git-intro-talk

Questions?


ben.holmes@it.ox.ac.uk