分布式版本管理
Upcoming SlideShare
Loading in...5
×
 

分布式版本管理

on

  • 1,559 views

 

Statistics

Views

Total Views
1,559
Views on SlideShare
1,518
Embed Views
41

Actions

Likes
1
Downloads
21
Comments
0

1 Embed 41

http://nbazaar.org 41

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

分布式版本管理 分布式版本管理 Presentation Transcript

  • DVCS
  • • Visual SourceSafe• CVS/Subversion/TFS/etc.• Git/Mercurial/Bazaar/etc.
  • Why?
  • Subversion, CVS, etc.••
  • • or•
  • CVS/SVN/etc. Git/Mercurial/etc. revision changeset
  • • ≠• merge•
  • • Mercurial SVN
  • % hgMercurial Distributed SCMbasic commands: add add the specified files on the next commit annotate show changeset information by line for each file clone make a copy of an existing repository commit commit the specified files or all outstanding changes diff diff repository (or selected files) export dump the header and diffs for one or more changesets forget forget the specified files on the next commit init create a new repository in the given directory log show revision history of entire repository or files merge merge working directory with another revision pull pull changes from the specified source push push changes to the specified destination remove remove the specified files on the next commit serve start stand-alone webserver status show changed files in the working directory summary summarize working directory state update update working directory (or switch revisions)use "hg help" for the full list of commands or "hg -v" for details
  • % pwd/Users/neo/Code/Repo/hginit% lltotal 24drwxr-xr-x 5 neo staff 170 Aug 7 13:13 .drwxr-xr-x 12 neo staff 408 Aug 7 13:11 ..-rw-r--r--@ 1 neo staff 1605 Jun 26 12:23 Info.plist-rw-r--r--@ 1 neo staff 2907 Jun 19 16:18 global.html-rw-r--r-- 1 neo staff 1183 Jun 12 16:22 link.png% hg init% lltotal 24drwxr-xr-x 6 neo staff 204 Aug 7 13:14 .drwxr-xr-x 12 neo staff 408 Aug 7 13:11 ..drwxr-xr-x 5 neo staff 170 Aug 7 13:14 .hg-rw-r--r--@ 1 neo staff 1605 Jun 26 12:23 Info.plist-rw-r--r--@ 1 neo staff 2907 Jun 19 16:18 global.html-rw-r--r-- 1 neo staff 1183 Jun 12 16:22 link.png
  • % hg add adding Info.plist adding global.html adding link.png % hg commit % hg log changeset: 0:0ae94e57c184% hg commit tag: tipInfo.plist user: "Neo Lee <neo.lee at gmail.com>"global.html date: Sat Aug 07 14:43:24 2010 +0800link.png files: Info.plist global.html link.pngcommitted changeset 0:0ae94e57c184 description: Init commit.
  • % hg commit% hg logchangeset: 1:dc12cb350527tag: tipuser: "Neo Lee <neo.lee at gmail.com>"date: Sat Aug 07 14:54:57 2010 +0800files: global.htmldescription:Capitalize ERROR prompt.changeset: 0:0ae94e57c184user: "Neo Lee <neo.lee at gmail.com>"date: Sat Aug 07 14:43:24 2010 +0800files: Info.plist global.html link.pngdescription:Init commit.
  • % rm Info.plist% rm link.png% e global.html%% hg revert --allreverting Info.plistreverting link.pngreverting global.html
  • 1.2.3. commit4. revert5. (1)
  • % cp Info.plist Info.plist.1% e Info.plist% rm link.pngremove link.png? y% hg statusM Info.plist! link.png? Info.plist.1% hg diff Info.plistdiff -r dc12cb350527 Info.plist--- a/Info.plist Sat Aug 07 14:54:57 2010 +0800+++ b/Info.plist Sat Aug 07 15:07:18 2010 +0800@@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>Author</key>- <string>Neo Lee</string>+ <string>Li Jun</string> <key>CFBundleDisplayName</key> <string>Goo.gl</string> <key>CFBundleIdentifier</key>
  • % hg log changeset: 2:5ba69dac6378 tag: tip user: "Neo Lee <neo.lee at gmail.com>"% hg remove link.png date: Sat Aug 07 15:10:02 2010 +0800removing link.png files: Info.plist Info.plist.1 link.png description:% hg status Some dirty work!M Info.plistR link.png? Info.plist.1 changeset: 1:dc12cb350527 user: "Neo Lee <neo.lee at gmail.com>"% hg add date: Sat Aug 07 14:54:57 2010 +0800adding Info.plist.1 files: global.html description:% hg st Capitalize ERROR prompt.M Info.plistA Info.plist.1R link.png changeset: 0:0ae94e57c184 user: "Neo Lee <neo.lee at gmail.com>"% hg commit date: Sat Aug 07 14:43:24 2010 +0800 files: Info.plist global.html link.png description: Init commit.
  • % hg cat Info.plist% hg cat -r 0 Info.plist% hg diff -r 0:1 Info.plist% hg update -r 0% hg up -r 1% hg up
  • % mkdir repo% cd repo% hg init% hg servelistening at http://8.oasis.local:8000/ (bound to *:8000)
  • % hg clone http://8.oasis.local:8000/ workingno changes foundupdating to branch defaultresolving manifests0 files updated, 0 files merged, 0 files removed, 0 files unresolved% cd working% lltotal 0drwxr-xr-x 3 neo staff 102 Aug 7 15:49 .drwxr-xr-x 4 neo staff 136 Aug 7 15:49 ..drwxr-xr-x 8 neo staff 272 Aug 7 15:49 .hg
  • % hg pushJoel pushing to http://8.oasis.local:8000/ searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files
  • Rose
  • % hg outgoing comparing with http://8.oasis.local:8000/ searching for changes changeset: 2:689026657682 tag: tip user: Rose M <rose@snda.com> date: Mon Feb 08 15:29:09 2010 -0500Rose summary: Spicier kind of chile. % hg push pushing to http://8.oasis.local:8000/ searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files
  • % hg outgoing comparing with http://8.oasis.local:8000/ searching for changes changeset: 2:4ecdb2401ab4 tag: tip user: Joel S <joel@snda.com> date: Mon Feb 08 15:32:01 2010 -0500 summary: potato chips. No one can eat just one. % hg push pushing to http://8.oasis.local:8000/ searching for changes abort: push creates new remote heads! (did you forget to merge? use push -f to force) % hg incomingJoel comparing with http://8.oasis.local:8000/ searching for changes changeset: 3:689026657682 tag: tip parent: 1:a52881ed530d user: Rose M <rose@example.com> date: Mon Feb 08 15:29:09 2010 -0500 summary: spicier kind of chile % hg pull pulling from http://8.oasis.local:8000/ searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run hg heads to see heads, hg merge to merge)
  • % hg merge merging guac 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, dont forget to commit) % hg commit -m "merge" % hg log changeset: 4:0849ca96c304 tag: tip parent: 2:4ecdb2401ab4 parent: 3:689026657682 user: Joel S <joel@snda.com> date: Mon Feb 08 16:07:23 2010 -0500 summary: mergeJoel ... ... % hg out comparing with http://8.oasis.local:8000// searching for changes changeset: 2:4ecdb2401ab4 ... ... changeset: 4:0849ca96c304 ... ... % hg push pushing to http://8.oasis.local:8000/ searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files
  • Rose % hg pull pulling from http://8.oasis.local:8000/ searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files (run hg update to get a working copy) % hg log % hg parent changeset: 2:689026657682 user: Rose H <rose@snda.com> date: Mon Feb 08 15:29:09 2010 -0500 summary: spicier kind of chile % hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  • • • hg revert • hg rollback commit pull• • hg clone project peoject-experiment
  • Backout % hg backout -m back out second change tip % hg backout --merge -m Back out second change. 1 reverting myfile created new head changeset 3:abc7fd860049 backs out changeset 1:7e341ee3be7a merging with changeset 3:abc7fd860049 merging myfile 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, dont forget to commit)1st change 2nd change 3rd change Automated merge Back-out 2nd change
  • • code base• pull• push• merge•
  • •• “ ”••
  • Subversion → Mercurial/Git?•• /
  • References• Mercurial: The Definitive Guide by Bryan OSullivan, http://hgbook.red-bean.com/• Hg Init: a Mercurial tutorial by Joel Spolsky, http://hginit.com/top/index.html• Git for the Lazy by Spheriki, http://www.spheredev.org/wiki/Git_for_the_lazy• PeepCode Git Internals by Scott Chacon
  • Contact Me• neo.lee@gmail.com• @soulhacker•
  • Questions?