This document provides an overview of version control with Git. It explains what version control and Git are, how to install and configure Git, how to perform basic tasks like initializing a repository and making commits, and how to collaborate using features like branching and pushing/pulling from remote repositories. Key points covered include allowing the tracking of changes, maintaining file history, and enabling multiple people to work on the same project simultaneously without conflicts.
5. What is
Version Control?
• Allows you to keep a history of every change
within a project.
6. What is
Version Control?
• Allows you to keep a history of every change
within a project.
• Allows multiple people to collaborate on the
same project, without evil stuff happening.
7. What is
Version Control?
• Allows you to keep a history of every change
within a project.
• Allows multiple people to collaborate on the
same project, without evil stuff happening.
• All files (and historical versions) are backed-
up automatically.
14. Installation
• Windows:
http://code.google.com/p/msysgit/
• Mac OSX:
http://code.google.com/p/git-osx-installer/
• Linux:
Packages available for most distros, or build from
source.
15. Configuring Git
• Configure your name and email address.
git config --global user.name = ‘leeky’
git config --global user.email = ‘leeky@leeky.org.uk’
• Using ‘--global’ makes these the default value
for all projects.
17. Starting a New
Git-Managed Project
• Create directory for project.
18. Starting a New
Git-Managed Project
• Create directory for project.
• cd into project directory.
19. Starting a New
Git-Managed Project
• Create directory for project.
• cd into project directory.
• Type git init to initialise Git for this
project.
20. Starting a New
Git-Managed Project
• Create directory for project.
• cd into project directory.
• Type git init to initialise Git for this
project.
Initialized empty Git repository in /git/demo/.git/
21. Terminology
• Repository - where the current and historical
file data is stored.
• Working copy - the local copy of files from a
repository, at a specific time or revision.
• Commit - copy files from your working copy to
the repository.These changes are stored together
as an individual revision.
22. Basic Git Workflow
1. Add, edit and delete files in your project in
the normal way, using your favourite editor
(e.g. TextMate,Vi, Dreamweaver etc).
2. Tell Git which file(s) are to be saved into the
new commit using git add
3. Commit files to repository using git commit.
24. Git Commands
• git status - View status of working copy.
• git add - Add unstaged changes.
- git add {filename} {filename} ...
- git add .
• git commit - Commit changes to repository.
- git commit -m “{message}”
25. More Git Commands
• git diff- Shows differences between
working copy and last revision.
• git log - Shows the history log.
- git log {filename} - Restrict log to file(s)
• git blame {filename} - Shows when/who
made changes to a file.
26. Git GUI
• Launch by running git gui in your project’s
directory.
• Gives you ability to add files and create
commits without using the command line!
27. Gitk
• Launch by running gitk in your project’s
directory.
• Allows you to browse the entire history of
your project and see when and by whom
files were changed.
28. Gitk
• Launch by running gitk in your project’s
directory.
• Allows you to browse the entire history of
your project and see when and by whom
files were changed.
33. Branching
• Allows experimental features to be
developed separately, without affecting stable
code.
• Branches can be easily created and later
merged together.
34. Branching
• Allows experimental features to be
developed separately, without affecting stable
code.
• Branches can be easily created and later
merged together.
Master Master
35. Branching
• Allows experimental features to be
developed separately, without affecting stable
code.
• Branches can be easily created and later
merged together.
Master Master
git branch Branch Branch
36. Branching
• Allows experimental features to be
developed separately, without affecting stable
code.
• Branches can be easily created and later
merged together.
Master Master Master Master
git branch Branch Branch
37. Branching
• Allows experimental features to be
developed separately, without affecting stable
code.
• Branches can be easily created and later
merged together.
Master Master Master Master Master
git branch Branch Branch git merge
39. Working with Branches
• git branch
- git branch - View branches.
- git branch {branchname} - Create a new
branch.
40. Working with Branches
• git branch
- git branch - View branches.
- git branch {branchname} - Create a new
branch.
• git checkout {branchname} - Switch to
another branch.
41. Working with Branches
• git branch
- git branch - View branches.
- git branch {branchname} - Create a new
branch.
• git checkout {branchname} - Switch to
another branch.
• git checkout -b {branchname} - Create new
branch and immediately switch to it.
49. Conflict Resolution
D O N ʼT
CONFLICT (add/add): Merge conflict in foo
IC !
Automatic merge failed; fix conflicts and
then commit the result.
N
PA
50. Conflict Resolution
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 1 different commit(s) each, respectively.
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# unmerged: foo
# no changes added to commit (use "git add" and/or "git commit -a")
51. Conflict Resolution
la la la
<<<<<<< HEAD:foo
wish
dog
cow
cat
=======
moo cow
fish
>>>>>>> 0cb13d1ceabf7e579b423815d8314fca0475ab7f:foo
Hello, my name is Robert Lee-Cann and I&#x2019;m a web developer.
In this talk I&#x2019;ll be introducing you to the basic concepts of version control - what it is, how it works and the benefits it will bring to your development workflow.
Hello, my name is Robert Lee-Cann and I&#x2019;m a web developer.
In this talk I&#x2019;ll be introducing you to the basic concepts of version control - what it is, how it works and the benefits it will bring to your development workflow.