Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

モデルから知るGit

11,595 views

Published on

Git初心者向けの解説です。図が中心。

  • Be the first to comment

モデルから知るGit

  1. 1. Git2011 3 9 (id:hiratara)
  2. 2. • (id:hiratara)•• Perl Python Java Haskell• Git
  3. 3. • Git•••
  4. 4. hoge.git/hoge/.git/ bare config config refs refs ... ... dir hoge/ dir .gitignore hoge.txt dir ...
  5. 5. Git
  6. 6. Git•• Linus•
  7. 7. Git
  8. 8. .git/• .git/config git config• .git/refs/...
  9. 9. Author: hirataraDate: 2/25 13:43:42typoindex.htmlimages/flower.gifcss/index.cssjs/index.js
  10. 10. • ( )• 2• ( root)•
  11. 11. •• = index.html = flower.gif index.js
  12. 12. git svnSVNGit A B C D
  13. 13. git svn git merge --squashSVNGit
  14. 14. git svn• git • git ID → • →
  15. 15. git•• →• ID
  16. 16. remotes/origin/mastertags/0.9973 heads/topic heads/master
  17. 17. =refs/heads• ref .git/refs • .git/refs/tags/ • .git/refs/heads/ • .git/refs/remotes/
  18. 18. ref• .git/• .git/refs/• .git/refs/tags/• .git/refs/heads/• .git/refs/remotes/
  19. 19. ref• 2 heads/hiratara/master remotes/hiratara/master• hiratara/master• remotes/hiratara/master
  20. 20. topic master
  21. 21. git commit(1)topic 1 master
  22. 22. git commit(2) topic1 2 master
  23. 23. topic1 2 master
  24. 24. git merge topic1 2 master
  25. 25. git commit(3) topic1 2 master 3
  26. 26. topic topic1 2 master 3
  27. 27. git commit(4) topic1 2 4 master 3
  28. 28. ID• ID →ID• ID → ID →ID
  29. 29. ID SHA1 • • ID
  30. 30. • ID →ID →• Git
  31. 31. topicB C master A
  32. 32. git rebaseB C B C master topic A B’ C’
  33. 33. topicB C master A
  34. 34. git cherry-pick B topic B C master A B
  35. 35. git cherry-pick C topic B C master A B C
  36. 36. masterA B C
  37. 37. rebase -i HEAD~3 master A B C A B C A B C
  38. 38. reflog • • git reflog show master C master
  39. 39. masterA B CA B C
  40. 40. git reset CA B C masterA B C
  41. 41. masterA B C
  42. 42. git revert A masterA B C -A
  43. 43. topic master
  44. 44. committopic master
  45. 45. git merge master topic master
  46. 46. 3.git topic master A B C D D D
  47. 47. • •• staged cached
  48. 48. .git topic master A B C D D D’
  49. 49. git add.git topic master A B C D add D’ D’
  50. 50. .git topic master A B C D D’ D’’
  51. 51. git add.git topic master A B C D add D’’ D’’
  52. 52. git commit.git topic master A B C D D’’ commit D’’ D’’
  53. 53. • D’ →•
  54. 54. 3.git topic master A B C D commit -a commit commit filename add D’ D’’
  55. 55. (1).git topic master A B C D D D
  56. 56. git checkout master.git topic master A B C D C C
  57. 57. (2).git topic master A B C D D D
  58. 58. git checkout master ..git topic master A B C D C C
  59. 59. git checkout ..git topic master A B C D D D
  60. 60. (1).git topic master A B C D C C
  61. 61. git reset --soft topic.git topic master A B C D C C
  62. 62. git reset topic.git topic master A B C D D C
  63. 63. git reset --hard topic.git topic master A B C D D D
  64. 64. • (origin/master )• git fetch git push
  65. 65. git@github.com:him/hoge.git A B C D master~/git-repos/hoge A B C X master
  66. 66. git remote addgithub => git@github.com:him/hoge.git A B C D master git remote add github git@...~/git-repos/hoge A B C X master
  67. 67. git fetchgithub => git@github.com:him/hoge.git A B C D master git fetch github~/git-repos/hoge ( git remote update) D github/master A B C X master
  68. 68. refspec•• push, fetch (fetch )githubheads/from git fetch github from:toheads/to ※ headsheads/to git push github from:toheads/from
  69. 69. fetch refspec• git remote add•
  70. 70. merge rebasegithub => git@github.com:him/hoge.git A B C D master~/git-repos/hoge git rebase github/master D github/master A B C X X` master
  71. 71. git pushgithub => git@github.com:him/hoge.git A B C D X` master~/git-repos/hoge git push github D github/master A B C X X` master
  72. 72. push refspec• refspec →" push"• push.default nothing, matching, tracking, current• remote.<name>.push (F/W fetch )
  73. 73. fetch pull push(1)github => git@github.com:him/hoge.githeads/masterheads/another git fetch github~/git-repos/hoge remote.<name>.fetchremotes/github/masterremotes/github/anotherheads/masterheads/local-branchheads/another
  74. 74. fetch pull push(2)github => git@github.com:him/hoge.githeads/masterheads/another branch.<name>.remote~/git-repos/hoge git pull = fetch + mergeremotes/github/masterremotes/github/another branch.<name>.mergeheads/masterheads/local-branchheads/another
  75. 75. fetch pull push(3)github => git@github.com:him/hoge.githeads/masterheads/another git push github~/git-repos/hoge push.default=matchingremotes/github/masterremotes/github/anotherheads/masterheads/local-branchheads/another
  76. 76. githuborigin/topic1 masterorigin/master topic1 master
  77. 77. hanako taro cloneorigin/topic1 masterorigin/master topic1 masterorigin/topic1origin/master
  78. 78. hanako topic2origin/topic1 masterorigin/master topic1 masterorigin/topic1 topic2origin/master
  79. 79. hanako taro forkorigin/topic1 masterorigin/master topic1 masterorigin/topic1 topic2origin/master topic1 master
  80. 80. git remote -f addorigin/topic1 master origin/master topic1 masterhanako/topic1 origin/topic1 topic2hanako/master origin/master topic1 master
  81. 81. git push hanako topic2origin/topic1 master origin/master topic1 masterhanako/topic1 origin/topic1 topic2 hanako/topic2 topic2hanako/master origin/master topic1 master
  82. 82. tarou pull-reqorigin/topic1 master origin/master topic1 master pull requesthanako/topic1 origin/topic1 topic2 hanako/topic2 topic2hanako/master origin/master topic1 master
  83. 83. taro remote addhanako/topic1 master hanako/topic2 origin/topic1hanako/master origin/master topic1 masterhanako/topic1 origin/topic1 topic2 hanako/topic2 topic2hanako/master origin/master topic1 master
  84. 84. merge hanako/topic2hanako/topic1 master hanako/topic2 origin/topic1hanako/master origin/master topic1 masterhanako/topic1 origin/topic1 topic2 hanako/topic2 topic2hanako/master origin/master topic1 master
  85. 85. git push origin masterhanako/topic1 master hanako/topic2 origin/topic1hanako/master origin/master master origin/master topic1hanako/topic1 origin/topic1 topic2 hanako/topic2 topic2hanako/master origin/master topic1 master
  86. 86. github
  87. 87. • git svn →• git

×