Gitting into Version Control

An Introduction to Git


Charelle Collett


Stop me if there's anything you don't understand!

Why use version control?

Why use version control?

Keeps a change history of every file

Branches let you, or several people, work on things concurrently

Auditing - where features were introduced, who worked on what


Not a replacement for backups!

Why Git?

Used by popular code hosting services like Gitlab, Github & Bitbucket

Creates a full copy of the whole repository (unlike SVN)

Open source

Powerful features

Remote repository

Local copy

Local copy

Local copy





"Don't try use git's features - that's how you break things"


You should use git's features


Install git:


apt-get install git

dnf install git

yum install git


Xcode Command Line Tools


Github for Windows:


Initialise the repository:

Clone an existing repository:

#  With --bare it doesn't create a working directory:
#  A good idea for shared repositories

$ git init --bare <directory>

$ git clone <URL>


$ git config --global "Charelle Collett"

$ git config --global ""

$ git config --global --edit

# Remove --global to change settings for a single project

Edit the config:


$ git status

See what changes will be applied:

$ git add <filename>

Add files to commit:

$ git commit -m "message"

Commit your changes:

$ git log

See the history:



new feature:

experiment based on new feature:


$ git checkout -b <name-of-branch>

Create a new branch:

This is shorthand for:

Move to a different branch:

$ git checkout <name-of-branch>

$ git branch <name-of-branch>

$ git checkout <name-of-branch>

Pushing / PUlling

$ git push

Remote repository

Local copy

Push your local changes to the remote repository:

$ git pull

Pull new changes from the remote repository to your local copy:




$ git push <remote> <branch>

Push to a specific branch:

Show connections to other repositories:

$ git remote -v

$ git pull <remote>

Pull from a certain remote:

$ git remote add <name> <url>

Add a remote:

$ git remote rm <name>

Remove a remote:

# Only push to a
# bare repository!

GIT Config


$ git config --edit

[branch "new-feature"]
	remote = origin
	merge = refs/heads/new-feature

More terms

Upstream: original source of the code

Fork: a copy of the code

Merge request / pull request: avenue to submit changes

Other useful things...

* cherry-pick

Take a commit and apply it to another branch

* rebase

Change the point where your changes are based

* stash

Save your changes locally (without committing) so you can switch branches

* squash

Combine several commits into one


* patch

Export changes as a patch that can be applied later

* .gitignore

List of files that git should ignore

* diff

See differences between commits

* blame

See who was responsible for changes

More Info

Git documentation:


Atlassian's git tutorial:


Github / Code school interactive tutorial:


Codecademy interactive tutorial:

Thank you!



Charelle Collett


Gitting into Version Control

By Charelle Collett


Gitting into Version Control

An Introduction to Git