GitThe fast version control systemJeroen Rosenberg jeroen.rosenberg@gmail.com
Table of contentsShort introduction to version controlVersion control systemsComparison with subversionDistributed version controlGit usageBasic operationsSolving conflictsBranching as a core conceptToolingConclusionGit - the fast version control system
Version controlShort introductionGit - the fast version control system
Version control (1)The management of changes to documents, programs, and other information stored as computer filesA system that maintains versions of files at progressive stages of development.Every fileHas a full history of changesCan be restored to any versionA communication tool, like email, but with code rather than human conversationGit - the fast version control system
Version control (2)BenefitsGit - the fast version control system
Version control (2)BenefitsAllows a team to share codeGit - the fast version control system
Version control (2)BenefitsAllows a team to share codeMaintains separate “production” versions of code that are always deployableGit - the fast version control system
Version control (2)BenefitsAllows a team to share codeMaintains separate “production” versions of code that are always deployableAllows simultaneous development of different features on the same codebaseGit - the fast version control system
Version control (2)BenefitsAllows a team to share codeMaintains separate “production” versions of code that are always deployableAllows simultaneous development of different features on the same codebaseKeeps track of all old versions of filesGit - the fast version control system
Version control (2)BenefitsAllows a team to share codeMaintains separate “production” versions of code that are always deployableAllows simultaneous development of different features on the same codebaseKeeps track of all old versions of filesPrevents work being overwrittenGit - the fast version control system
GlossarySome commonly used terms explained before moving onGit - the fast version control system
Key terms in version controlBranch acopy of a set of files under version control which may be developed at different speeds or in different waysCheckout to copy the latest version of (a file in) the repository to your working copyCommit to copy (a file in) your working copy back into the repository as a new version  Merge to combine multiple changes made to different working copies of the same files in the repositoryRepository a (shared) database with the complete revision history of all files under version controlTrunk the unique line of development that is not a branchUpdate to retrieve and integrate changes in the repository since the update.Working copy your local copies of the files under version control you want to editGit - the fast version control system
Version control systemsGit - the fast version control system
Very limited and inflexibleConcurrent Versions System (CVS)Git - the fast version control system
Very limited and inflexibleConcurrent Versions System (CVS)Fills most of the holes found in CVS, but added nothing to its development model Subversion (SVN)Git - the fast version control system
Very limited and inflexibleConcurrent Versions System (CVS)Fills most of the holes found in CVS, but added nothing to its development model Subversion (SVN)More feature rich and functionalGitGit - the fast version control system
Comparison with SVNSubversionGitGit - the fast version control system
Comparison with SVNSubversionCentralizedGitDistributedGit - the fast version control system
Comparison with SVNSubversionCentralizedBranching can be a pain and is used sparinglyGitDistributedBranching is very easy and is a core conceptGit - the fast version control system
Comparison with SVNSubversionCentralizedBranching can be a pain and is used sparinglyConflicts frequently occur and renaming is not handled wellGitDistributedBranching is very easy and is a core conceptConflicts occur less frequent, renaming is properly handledGit - the fast version control system
Comparison with SVNSubversionCentralizedBranching can be a pain and is used sparinglyConflicts frequently occur and renaming is not handled wellCan be slow due to network latencyGitDistributedBranching is very easy and is a core conceptConflicts occur less frequent, renaming is properly handledVery fast since less operations involve network latencyGit - the fast version control system
Comparison with SVNSubversionCentralizedBranching can be a pain and is used sparinglyConflicts frequently occur and renaming is not handled wellCan be slow due to network latencyCan consume quite some disk spaceGitDistributedBranching is very easy and is a core conceptConflicts occur less frequent, renaming is properly handledVery fast since less operations involve network latencyConsumes 30 times less disk spaceGit - the fast version control system
Distributed version control The new generation of version controlGit - the fast version control system
A basic, centralized version control systemUsers commit changes to the central repository and a new version is born to be checked out by other usersGit - the fast version control system
A distributed version control systemEach user has a full local copy of the repository. Users commit changes and when they want to share it, the push it to the shared repository Git - the fast version control system
Git usageBasic operationsGit - the fast version control system
Tracking a project..Git - the fast version control system
Tracking a project..Mirror the central serverAnything the main repository can do, you can do!Git - the fast version control system
Tracking a project..My project is tiny - git is overkill“Why would I carry a Swiss knife when I only want to open cans?”Git - the fast version control system
Tracking a project..Tiny projects should be scalable too!“You wouldn’t use Roman digits just because you perform calculations with small numbers, now would you?”Tiny projects may grow beyond your expectations“One day you’ll desperately need that hex wrench and you’re stuck with your plain can-opener”Git - the fast version control system
Tracking a project..Pretty straightforwarded, huh?Git - the fast version control system
Advanced committing…What if you screw up?#re-edit the metadata and update the tree$ git commit --amendor# toss your latest commit away without changing the working tree$ git reset HEAD^ Git - the fast version control system
Solving conflictsInstant mergingGit - the fast version control system
Closer look at pulling..Git - the fast version control system
Auto-merging..What actually happens…# Fetch latest changes from origin$ git fetch# Merge fetched changes into current branch$ git merge refs/heads/masterGit - the fast version control system
Auto-merging..What actually happens…Recursive merge strategy – create a merged reference tree of common ancestors for three-way merge  fewer merge conflicts
 can detect and handle renamesGit - the fast version control system
Resolving conflicts..Suppose Jeff and Dan both made changes to the same line in file…CONFLICT (content): Merge conflict in fileAutomatic merge failed; fix conflicts and then commit the result.Uh oh…. now what?Git - the fast version control system
Resolving conflicts..Well, just merge manually…# run your favourite file merge application$ git mergetool –t opendiffGit - the fast version control system
Git - the fast version control systemsource: http://gitguru.com
Resolving conflicts..…and commit!# commit to resolve the conflict$ git commitGit - the fast version control system
BranchingA core conceptGit - the fast version control system
Creating a branch..Git - the fast version control system
Creating a branch..Or create and switch to a branch based on another branch$ git checkout –b new_branch other_branchGit - the fast version control system
Some common scenarios…Git - the fast version control systemWhy would I require branching?
Scenario 1 – Interrupted workflowYou’re finished with part 1 of a new feature but you can’t continue with part 2 before part 1 is released and tested  Git - the fast version control system
Scenario 1 – Interrupted workflowYou’re finished with part 1 of a new feature but you can’t continue with part 2 before part 1 is released and tested  Git - the fast version control system
Scenario 2 – Quick fixesWhile you’re busy implementing some feature suddenly you’re being told to drop everything and fix a newly discovered bugGit - the fast version control system
Scenario 2 – Quick fixesWhile you’re busy implementing some feature suddenly you’re being told to drop everything and fix a newly discovered bugGit - the fast version control system
Git usage overviewJust to summarize…Git - the fast version control system
Git command sequenceSource: http://git.or.czGit - the fast version control system
ToolingStuck at ‘Ye Olde Terminal’? Not necessarily…Git - the fast version control system
Git UI front-endsGit - the fast version control system
 OpenInGitGuiGit - the fast version control systemFinder extension
 OpenInGitGuiGit - the fast version control systemFinder extension TortoiseGit
 Git ExtensionsWindows Explorer extensions
 OpenInGitGuiGit - the fast version control systemFinder extension TortoiseGit
 Git ExtensionsWindows Explorer extensions JGit / EGitEclipse integration