ebook img

Pro Git [electronic resource] PDF

2009·5.4 MB·English
by  ChaconScott
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro Git [electronic resource]

Pro Git ScottChacon July29,2009 Contents 1 GettingStarted 1 1.1 AboutVersionControl . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 LocalVersionControlSystems. . . . . . . . . . . . . . . . . 1 1.1.2 CentralizedVersionControlSystems . . . . . . . . . . . . . 2 1.1.3 DistributedVersionControlSystems . . . . . . . . . . . . . . 3 1.2 AShortHistoryofGit . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 GitBasics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.1 Snapshots,NotDifferences . . . . . . . . . . . . . . . . . . . 4 1.3.2 NearlyEveryOperationIsLocal . . . . . . . . . . . . . . . . 5 1.3.3 GitHasIntegrity . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3.4 GitGenerallyOnlyAddsData . . . . . . . . . . . . . . . . . 6 1.3.5 TheThreeStates . . . . . . . . . . . . . . . . . . . . . . . . 6 1.4 InstallingGit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4.1 InstallingfromSource . . . . . . . . . . . . . . . . . . . . . 8 1.4.2 InstallingonLinux . . . . . . . . . . . . . . . . . . . . . . . 8 1.4.3 InstallingonMac . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4.4 InstallingonWindows . . . . . . . . . . . . . . . . . . . . . 9 1.5 First-TimeGitSetup . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5.1 YourIdentity . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5.2 YourEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5.3 YourDiffTool . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.5.4 CheckingYourSettings . . . . . . . . . . . . . . . . . . . . 11 1.6 GettingHelp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2 GitBasics 13 2.1 GettingaGitRepository . . . . . . . . . . . . . . . . . . . . . . . . 13 2.1.1 InitializingaRepositoryinanExistingDirectory . . . . . . . 13 2.1.2 CloninganExistingRepository . . . . . . . . . . . . . . . . 14 2.2 RecordingChangestotheRepository . . . . . . . . . . . . . . . . . 14 2.2.1 CheckingtheStatusofYourFiles . . . . . . . . . . . . . . . 15 2.2.2 TrackingNewFiles . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.3 StagingModifiedFiles . . . . . . . . . . . . . . . . . . . . . 16 2.2.4 IgnoringFiles . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2.5 ViewingYourStagedandUnstagedChanges . . . . . . . . . 18 2.2.6 CommittingYourChanges . . . . . . . . . . . . . . . . . . . 20 2.2.7 SkippingtheStagingArea . . . . . . . . . . . . . . . . . . . 22 i PROGIT SCOTTCHACON 2.2.8 RemovingFiles . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2.9 MovingFiles . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.3 ViewingtheCommitHistory . . . . . . . . . . . . . . . . . . . . . . 24 2.3.1 LimitingLogOutput . . . . . . . . . . . . . . . . . . . . . . 27 2.3.2 UsingaGUItoVisualizeHistory . . . . . . . . . . . . . . . 29 2.4 UndoingThings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.4.1 ChangingYourLastCommit . . . . . . . . . . . . . . . . . . 30 2.4.2 UnstagingaStagedFile . . . . . . . . . . . . . . . . . . . . 30 2.4.3 UnmodifyingaModifiedFile . . . . . . . . . . . . . . . . . 31 2.5 WorkingwithRemotes . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.5.1 ShowingYourRemotes. . . . . . . . . . . . . . . . . . . . . 32 2.5.2 AddingRemoteRepositories . . . . . . . . . . . . . . . . . . 33 2.5.3 FetchingandPullingfromYourRemotes . . . . . . . . . . . 33 2.5.4 PushingtoYourRemotes . . . . . . . . . . . . . . . . . . . . 34 2.5.5 InspectingaRemote . . . . . . . . . . . . . . . . . . . . . . 34 2.5.6 RemovingandRenamingRemotes. . . . . . . . . . . . . . . 35 2.6 Tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.6.1 ListingYourTags . . . . . . . . . . . . . . . . . . . . . . . . 36 2.6.2 CreatingTags . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.6.3 AnnotatedTags . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.6.4 SignedTags . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.6.5 LightweightTags . . . . . . . . . . . . . . . . . . . . . . . . 38 2.6.6 VerifyingTags . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.6.7 TaggingLater . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.6.8 SharingTags . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.7 TipsandTricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.7.1 Auto-Completion . . . . . . . . . . . . . . . . . . . . . . . . 40 2.7.2 GitAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3 GitBranching 43 3.1 WhataBranchIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.2 BasicBranchingandMerging . . . . . . . . . . . . . . . . . . . . . 48 3.2.1 BasicBranching . . . . . . . . . . . . . . . . . . . . . . . . 48 3.2.2 BasicMerging . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.2.3 BasicMergeConflicts . . . . . . . . . . . . . . . . . . . . . 53 3.3 BranchManagement . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.4 BranchingWorkflows . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.4.1 Long-RunningBranches . . . . . . . . . . . . . . . . . . . . 56 3.4.2 TopicBranches . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.5 RemoteBranches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.5.1 Pushing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.5.2 TrackingBranches . . . . . . . . . . . . . . . . . . . . . . . 62 3.5.3 DeletingRemoteBranches . . . . . . . . . . . . . . . . . . . 63 3.6 Rebasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.6.1 TheBasicRebase . . . . . . . . . . . . . . . . . . . . . . . . 64 3.6.2 MoreInterestingRebases. . . . . . . . . . . . . . . . . . . . 65 3.6.3 ThePerilsofRebasing . . . . . . . . . . . . . . . . . . . . . 68 ii CHAPTER0 CONTENTS 3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 4 GitontheServer 71 4.1 TheProtocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.1.1 LocalProtocol . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.1.2 TheSSHProtocol . . . . . . . . . . . . . . . . . . . . . . . 73 4.1.3 TheGitProtocol . . . . . . . . . . . . . . . . . . . . . . . . 73 4.1.4 TheHTTP/SProtocol . . . . . . . . . . . . . . . . . . . . . 74 4.2 GettingGitonaServer . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.2.1 PuttingtheBareRepositoryonaServer . . . . . . . . . . . . 76 4.2.2 SmallSetups . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.3 GeneratingYourSSHPublicKey. . . . . . . . . . . . . . . . . . . . 77 4.4 SettingUptheServer . . . . . . . . . . . . . . . . . . . . . . . . . . 78 4.5 PublicAccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 4.6 GitWeb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 4.7 Gitosis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 4.8 GitDaemon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 4.9 HostedGit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.9.1 GitHub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.9.2 SettingUpaUserAccount . . . . . . . . . . . . . . . . . . . 88 4.9.3 CreatingaNewRepository . . . . . . . . . . . . . . . . . . . 89 4.9.4 ImportingfromSubversion . . . . . . . . . . . . . . . . . . . 92 4.9.5 AddingCollaborators . . . . . . . . . . . . . . . . . . . . . . 92 4.9.6 YourProject . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.9.7 ForkingProjects . . . . . . . . . . . . . . . . . . . . . . . . 94 4.9.8 GitHubSummary . . . . . . . . . . . . . . . . . . . . . . . . 94 4.10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 5 DistributedGit 97 5.1 DistributedWorkflows . . . . . . . . . . . . . . . . . . . . . . . . . 97 5.1.1 CentralizedWorkflow . . . . . . . . . . . . . . . . . . . . . 97 5.1.2 Integration-ManagerWorkflow. . . . . . . . . . . . . . . . . 98 5.1.3 DictatorandLieutenantsWorkflow . . . . . . . . . . . . . . 99 5.2 ContributingtoaProject . . . . . . . . . . . . . . . . . . . . . . . . 100 5.2.1 CommitGuidelines . . . . . . . . . . . . . . . . . . . . . . . 100 5.2.2 PrivateSmallTeam . . . . . . . . . . . . . . . . . . . . . . . 102 5.2.3 PrivateManagedTeam . . . . . . . . . . . . . . . . . . . . . 107 5.2.4 PublicSmallProject . . . . . . . . . . . . . . . . . . . . . . 111 5.2.5 PublicLargeProject . . . . . . . . . . . . . . . . . . . . . . 115 5.2.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 5.3 MaintainingaProject . . . . . . . . . . . . . . . . . . . . . . . . . . 117 5.3.1 WorkinginTopicBranches. . . . . . . . . . . . . . . . . . . 117 5.3.2 ApplyingPatchesfromE-mail . . . . . . . . . . . . . . . . . 118 5.3.3 CheckingOutRemoteBranches . . . . . . . . . . . . . . . . 121 5.3.4 DeterminingWhatIsIntroduced . . . . . . . . . . . . . . . . 121 5.3.5 IntegratingContributedWork . . . . . . . . . . . . . . . . . 123 5.3.6 TaggingYourReleases . . . . . . . . . . . . . . . . . . . . . 127 5.3.7 GeneratingaBuildNumber . . . . . . . . . . . . . . . . . . 128 iii PROGIT SCOTTCHACON 5.3.8 PreparingaRelease . . . . . . . . . . . . . . . . . . . . . . . 129 5.3.9 TheShortlog . . . . . . . . . . . . . . . . . . . . . . . . . . 129 5.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6 GitTools 131 6.1 RevisionSelection . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1.1 SingleRevisions . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1.2 ShortSHA . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1.3 ASHORTNOTEABOUTSHA–1 . . . . . . . . . . . . . . 132 6.1.4 BranchReferences . . . . . . . . . . . . . . . . . . . . . . . 133 6.1.5 RefLogShortnames . . . . . . . . . . . . . . . . . . . . . . 133 6.1.6 AncestryReferences . . . . . . . . . . . . . . . . . . . . . . 134 6.1.7 CommitRanges. . . . . . . . . . . . . . . . . . . . . . . . . 136 6.2 InteractiveStaging . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 6.2.1 StagingandUnstagingFiles . . . . . . . . . . . . . . . . . . 138 6.2.2 StagingPatches . . . . . . . . . . . . . . . . . . . . . . . . . 140 6.3 Stashing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 6.3.1 StashingYourWork . . . . . . . . . . . . . . . . . . . . . . 141 6.3.2 CreatingaBranchfromaStash . . . . . . . . . . . . . . . . 143 6.4 RewritingHistory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 6.4.1 ChangingtheLastCommit . . . . . . . . . . . . . . . . . . . 144 6.4.2 ChangingMultipleCommitMessages . . . . . . . . . . . . . 145 6.4.3 ReorderingCommits . . . . . . . . . . . . . . . . . . . . . . 146 6.4.4 SquashingaCommit . . . . . . . . . . . . . . . . . . . . . . 147 6.4.5 SplittingaCommit . . . . . . . . . . . . . . . . . . . . . . . 147 6.4.6 TheNuclearOption: filter-branch . . . . . . . . . . . . . . . 148 6.5 DebuggingwithGit . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 6.5.1 FileAnnotation . . . . . . . . . . . . . . . . . . . . . . . . . 150 6.5.2 BinarySearch . . . . . . . . . . . . . . . . . . . . . . . . . . 151 6.6 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 6.6.1 StartingwithSubmodules . . . . . . . . . . . . . . . . . . . 153 6.6.2 CloningaProjectwithSubmodules . . . . . . . . . . . . . . 154 6.6.3 Superprojects . . . . . . . . . . . . . . . . . . . . . . . . . . 156 6.6.4 IssueswithSubmodules . . . . . . . . . . . . . . . . . . . . 157 6.7 SubtreeMerging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 6.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 7 CustomizingGit 161 7.1 GitConfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 7.1.1 BasicClientConfiguration . . . . . . . . . . . . . . . . . . . 162 7.1.2 ColorsinGit . . . . . . . . . . . . . . . . . . . . . . . . . . 164 7.1.3 ExternalMergeandDiffTools . . . . . . . . . . . . . . . . . 164 7.1.4 FormattingandWhitespace . . . . . . . . . . . . . . . . . . 167 7.1.5 ServerConfiguration . . . . . . . . . . . . . . . . . . . . . . 168 7.2 GitAttributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 7.2.1 BinaryFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 7.2.2 KeywordExpansion . . . . . . . . . . . . . . . . . . . . . . 172 7.2.3 ExportingYourRepository . . . . . . . . . . . . . . . . . . . 174 iv CHAPTER0 CONTENTS 7.2.4 MergeStrategies . . . . . . . . . . . . . . . . . . . . . . . . 175 7.3 GitHooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 7.3.1 InstallingaHook . . . . . . . . . . . . . . . . . . . . . . . . 175 7.3.2 Client-SideHooks . . . . . . . . . . . . . . . . . . . . . . . 175 7.3.3 Server-SideHooks . . . . . . . . . . . . . . . . . . . . . . . 177 7.4 AnExampleGit-EnforcedPolicy . . . . . . . . . . . . . . . . . . . . 178 7.4.1 Server-SideHook . . . . . . . . . . . . . . . . . . . . . . . . 178 7.4.2 Client-SideHooks . . . . . . . . . . . . . . . . . . . . . . . 183 7.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 8 GitandOtherSystems 187 8.1 GitandSubversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 8.1.1 gitsvn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 8.1.2 SettingUp . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 8.1.3 GettingStarted . . . . . . . . . . . . . . . . . . . . . . . . . 189 8.1.4 CommittingBacktoSubversion . . . . . . . . . . . . . . . . 190 8.1.5 PullinginNewChanges . . . . . . . . . . . . . . . . . . . . 191 8.1.6 GitBranchingIssues . . . . . . . . . . . . . . . . . . . . . . 192 8.1.7 SubversionBranching . . . . . . . . . . . . . . . . . . . . . 193 8.1.8 SwitchingActiveBranches . . . . . . . . . . . . . . . . . . . 194 8.1.9 SubversionCommands . . . . . . . . . . . . . . . . . . . . . 194 8.1.10 Git-SvnSummary . . . . . . . . . . . . . . . . . . . . . . . 196 8.2 MigratingtoGit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 8.2.1 Importing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 8.2.2 Subversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 8.2.3 Perforce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 8.2.4 ACustomImporter . . . . . . . . . . . . . . . . . . . . . . . 200 8.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 9 GitInternals 205 9.1 PlumbingandPorcelain . . . . . . . . . . . . . . . . . . . . . . . . . 205 9.2 GitObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 9.2.1 TreeObjects . . . . . . . . . . . . . . . . . . . . . . . . . . 208 9.2.2 CommitObjects . . . . . . . . . . . . . . . . . . . . . . . . 210 9.2.3 ObjectStorage . . . . . . . . . . . . . . . . . . . . . . . . . 212 9.3 GitReferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 9.3.1 TheHEAD . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 9.3.2 Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 9.3.3 Remotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 9.4 Packfiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 9.5 TheRefspec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 9.5.1 PushingRefspecs . . . . . . . . . . . . . . . . . . . . . . . . 221 9.5.2 DeletingReferences . . . . . . . . . . . . . . . . . . . . . . 221 9.6 TransferProtocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 9.6.1 TheDumbProtocol . . . . . . . . . . . . . . . . . . . . . . . 222 9.6.2 TheSmartProtocol . . . . . . . . . . . . . . . . . . . . . . . 224 9.7 MaintenanceandDataRecovery . . . . . . . . . . . . . . . . . . . . 225 9.7.1 Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . 226 v PROGIT SCOTTCHACON 9.7.2 DataRecovery . . . . . . . . . . . . . . . . . . . . . . . . . 226 9.7.3 RemovingObjects . . . . . . . . . . . . . . . . . . . . . . . 228 9.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 vi Chapter 1 Getting Started ThischapterwillbeaboutgettingstartedwithGit. Wewillbeginatthebeginningby explainingsomebackgroundonversioncontroltools,thenmoveontohowtogetGit runningonyoursystemandfinallyhowtogetitsetuptostartworkingwith. Attheend of this chapter you should understand why Git is around, why you should use it and youshouldbeallsetuptodoso. 1.1 About Version Control What is version control, and why should you care? Version control is a system that recordschangestoafileorsetoffilesovertimesothatyoucanrecallspecificversions later. Fortheexamplesinthisbookyouwillusesoftwaresourcecodeasthefilesbeing version controlled, though inreality you cando this withnearly any typeof file ona computer. If you are a graphic or web designer and want to keep every version of an image orlayout(whichyouwouldmostcertainlywantto),aVersionControlSystem(VCS) isaverywisethingtouse. Itallowsyoutorevertfilesbacktoapreviousstate,revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when,andmore. UsingaVCSalsogenerallymeansthatifyouscrewthingsuporlose files,youcaneasilyrecover. Inaddition,yougetallthisforverylittleoverhead. 1.1.1 LocalVersionControlSystems Manypeople’sversion-controlmethodofchoiceistocopyfilesintoanotherdirectory (perhaps a time-stamped directory, if they’re clever). This approach is very common becauseitissosimple,butitisalsoincrediblyerrorprone. Itiseasytoforgetwhich directoryyou’reinandaccidentallywritetothewrongfileorcopyoverfilesyoudon’t meanto. To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control (see Figure 1.1). One of the more popular VCS tools was a system called rcs, which is still dis- tributed with many computers today. Even the popular Mac OS X operating system 1 PROGIT SCOTTCHACON Figure1.1: Localversioncontroldiagram includes the rcs command when you install the Developer Tools. This tool basically worksbykeepingpatchsets(thatis,thedifferencesbetweenfiles)fromonechangeto another in a special format on disk; it can then re-create what any file looked like at anypointintimebyaddingupallthepatches. 1.1.2 CentralizedVersionControlSystems The next major issue that people encounter is that they need to collaborate with de- velopers on other systems. To deal with this problem, Centralized Version Control Systems(CVCSs)weredeveloped. Thesesystems,suchasCVS,Subversion,andPer- force,haveasingleserverthatcontainsalltheversionedfiles,andanumberofclients thatcheckoutfilesfromthatcentralplace. Formanyyears,thishasbeenthestandard forversioncontrol(seeFigure1.2). Figure1.2: Centralizedversioncontroldiagram 2 CHAPTER1 GETTINGSTARTED Thissetupoffersmanyadvantages, especiallyoverlocalVCSs. Forexample, ev- eryoneknowstoacertaindegreewhateveryoneelseontheprojectisdoing. Adminis- tratorshavefine-grainedcontroloverwhocandowhat;andit’sfareasiertoadminister aCVCSthanitistodealwithlocaldatabasesoneveryclient. However, this setup also has some serious downsides. The most obvious is the singlepointoffailurethatthecentralizedserverrepresents.Ifthatservergoesdownfor anhour,thenduringthathournobodycancollaborateatallorsaveversionedchanges to anything they’re working on. If the hard disk the central database is on becomes corrupted,andproperbackupshaven’tbeenkept,youloseabsolutelyeverything—the entirehistoryoftheprojectexceptwhateversinglesnapshotspeoplehappentohaveon their local machines. Local VCS systems suffer from this same problem—whenever youhavetheentirehistoryoftheprojectinasingleplace,yourisklosingeverything. 1.1.3 DistributedVersionControlSystems ThisiswhereDistributedVersionControlSystems(DVCSs)stepin. InaDVCS(such asGit,Mercurial,BazaarorDarcs),clientsdon’tjustcheckoutthelatestsnapshotof the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it. Every checkout is really a full backup of all the data (see Figure 1.3). Figure1.3: Distributedversioncontroldiagram Furthermore, many of these systems deal pretty well with having several remote repositoriestheycanworkwith,soyoucancollaboratewithdifferentgroupsofpeople 3

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.