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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

分布式版本管理

1,409

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,409
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
24
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DVCS
  • 2. • Visual SourceSafe• CVS/Subversion/TFS/etc.• Git/Mercurial/Bazaar/etc.
  • 3. Why?
  • 4.
  • 5. Subversion, CVS, etc.••
  • 6. • or•
  • 7.
  • 8. CVS/SVN/etc. Git/Mercurial/etc. revision changeset
  • 9. • ≠• merge•
  • 10. • Mercurial SVN
  • 11. % 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
  • 12. % 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
  • 13. % 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.
  • 14. % 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.
  • 15. % rm Info.plist% rm link.png% e global.html%% hg revert --allreverting Info.plistreverting link.pngreverting global.html
  • 16. 1.2.3. commit4. revert5. (1)
  • 17. % 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>
  • 18. % 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.
  • 19. % 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
  • 20. % mkdir repo% cd repo% hg init% hg servelistening at http://8.oasis.local:8000/ (bound to *:8000)
  • 21. % 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
  • 22. % 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
  • 23. Rose
  • 24. % 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
  • 25. % 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)
  • 26. % 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
  • 27. 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
  • 28. • • hg revert • hg rollback commit pull• • hg clone project peoject-experiment
  • 29. 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
  • 30. • code base• pull• push• merge•
  • 31. •• “ ”••
  • 32. Subversion → Mercurial/Git?•• /
  • 33. 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
  • 34. Contact Me• neo.lee@gmail.com• @soulhacker•
  • 35. Questions?

×