commonmarker 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of commonmarker might be problematic. Click here for more details.

Files changed (501) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +67 -42
  4. data/Rakefile +22 -2
  5. data/commonmarker.gemspec +13 -9
  6. data/ext/commonmarker/cmark/api_test/main.c +35 -0
  7. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +12 -12
  8. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +141 -141
  9. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/main.c.o +0 -0
  10. data/ext/commonmarker/cmark/build/api_test/api_test +0 -0
  11. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_html_u.c.o +0 -0
  12. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/iterator.c.o +0 -0
  13. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_html_u.c.o +0 -0
  14. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/iterator.c.o +0 -0
  15. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
  16. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
  17. data/ext/commonmarker/cmark/build/src/cmark +0 -0
  18. data/ext/commonmarker/cmark/build/src/libcmark.0.19.0.dylib +0 -0
  19. data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
  20. data/ext/commonmarker/cmark/build/src/libcmark.dylib +0 -0
  21. data/ext/commonmarker/cmark/src/houdini_html_u.c +26 -13
  22. data/ext/commonmarker/cmark/src/iterator.c +2 -2
  23. data/ext/commonmarker/cmark/test/__pycache__/cmark.cpython-34.pyc +0 -0
  24. data/ext/commonmarker/cmark/test/__pycache__/normalize.cpython-34.pyc +0 -0
  25. data/ext/commonmarker/cmark/test/cmark.pyc +0 -0
  26. data/ext/commonmarker/cmark/test/normalize.pyc +0 -0
  27. data/ext/commonmarker/commonmarker.c +276 -3
  28. data/ext/commonmarker/extconf.rb +3 -1
  29. data/lib/commonmarker.rb +70 -360
  30. data/lib/commonmarker/config.rb +1 -1
  31. data/lib/commonmarker/renderer.rb +91 -0
  32. data/lib/commonmarker/renderer/html_renderer.rb +149 -0
  33. data/lib/commonmarker/version.rb +1 -1
  34. data/test/benchinput.md +148414 -0
  35. data/test/benchmark.rb +13 -9
  36. data/test/progit/Gemfile +5 -0
  37. data/test/progit/README.md +9 -0
  38. data/test/progit/README.original.md +70 -0
  39. data/test/progit/Rakefile +285 -0
  40. data/test/progit/ar/01-introduction/01-chapter1.markdown +264 -0
  41. data/test/progit/ar/02-git-basics/01-chapter2.markdown +1124 -0
  42. data/test/progit/ar/NOTES +18 -0
  43. data/test/progit/ar/README +14 -0
  44. data/test/progit/az/01-introduction/01-chapter1.markdown +257 -0
  45. data/test/progit/az/02-git-basics/01-chapter2.markdown +1127 -0
  46. data/test/progit/az/03-git-branching/01-chapter3.markdown +598 -0
  47. data/test/progit/az/04-git-server/01-chapter4.markdown +861 -0
  48. data/test/progit/az/05-distributed-git/01-chapter5.markdown +897 -0
  49. data/test/progit/az/06-git-tools/01-chapter6.markdown +1126 -0
  50. data/test/progit/az/07-customizing-git/01-chapter7.markdown +937 -0
  51. data/test/progit/az/08-git-and-other-scms/01-chapter8.markdown +690 -0
  52. data/test/progit/az/09-git-internals/01-chapter9.markdown +977 -0
  53. data/test/progit/be/01-introduction/01-chapter1.markdown +257 -0
  54. data/test/progit/be/02-git-basics/01-chapter2.markdown +1126 -0
  55. data/test/progit/ca/01-introduction/01-chapter1.markdown +257 -0
  56. data/test/progit/ca/README.txt +1 -0
  57. data/test/progit/couchapp/Makefile +41 -0
  58. data/test/progit/couchapp/Readme.md +17 -0
  59. data/test/progit/couchapp/_id +1 -0
  60. data/test/progit/couchapp/shows/chapter.js +14 -0
  61. data/test/progit/couchapp/templates/foot.html +7 -0
  62. data/test/progit/couchapp/templates/head.html +51 -0
  63. data/test/progit/couchapp/vendor/markdown/showdown.js +420 -0
  64. data/test/progit/couchapp/vendor/mustache.js/mustache.js +302 -0
  65. data/test/progit/cs/01-introduction/01-chapter1.markdown +259 -0
  66. data/test/progit/cs/02-git-basics/01-chapter2.markdown +1225 -0
  67. data/test/progit/cs/03-git-branching/01-chapter3.markdown +606 -0
  68. data/test/progit/cs/04-git-server/01-chapter4.markdown +871 -0
  69. data/test/progit/cs/05-distributed-git/01-chapter5.markdown +914 -0
  70. data/test/progit/cs/06-git-tools/01-chapter6.markdown +1167 -0
  71. data/test/progit/cs/07-customizing-git/01-chapter7.markdown +940 -0
  72. data/test/progit/cs/08-git-and-other-scms/01-chapter8.markdown +700 -0
  73. data/test/progit/cs/09-git-internals/01-chapter9.markdown +1014 -0
  74. data/test/progit/de/01-introduction/01-chapter1.markdown +445 -0
  75. data/test/progit/de/02-git-basics/01-chapter2.markdown +1589 -0
  76. data/test/progit/de/03-git-branching/01-chapter3.markdown +964 -0
  77. data/test/progit/de/04-git-server/01-chapter4.markdown +1337 -0
  78. data/test/progit/de/05-distributed-git/01-chapter5.markdown +1329 -0
  79. data/test/progit/de/06-git-tools/01-chapter6.markdown +1502 -0
  80. data/test/progit/de/07-customizing-git/01-chapter7.markdown +1361 -0
  81. data/test/progit/de/08-git-and-other-scms/01-chapter8.markdown +919 -0
  82. data/test/progit/de/09-git-internals/01-chapter9.markdown +1361 -0
  83. data/test/progit/de/README.md +626 -0
  84. data/test/progit/ebooks/cover.png +0 -0
  85. data/test/progit/en/01-introduction/01-chapter1.markdown +263 -0
  86. data/test/progit/en/02-git-basics/01-chapter2.markdown +1228 -0
  87. data/test/progit/en/03-git-branching/01-chapter3.markdown +606 -0
  88. data/test/progit/en/04-git-server/01-chapter4.markdown +871 -0
  89. data/test/progit/en/05-distributed-git/01-chapter5.markdown +914 -0
  90. data/test/progit/en/06-git-tools/01-chapter6.markdown +1150 -0
  91. data/test/progit/en/07-customizing-git/01-chapter7.markdown +940 -0
  92. data/test/progit/en/08-git-and-other-scms/01-chapter8.markdown +700 -0
  93. data/test/progit/en/09-git-internals/01-chapter9.markdown +983 -0
  94. data/test/progit/eo/01-introduction/01-chapter1.markdown +257 -0
  95. data/test/progit/eo/02-git-basics/01-chapter2.markdown +1171 -0
  96. data/test/progit/epub/ProGit.css +28 -0
  97. data/test/progit/epub/title.png +0 -0
  98. data/test/progit/es-ni/01-introduction/01-chapter1.markdown +257 -0
  99. data/test/progit/es-ni/02-git-basics/01-chapter2.markdown +1127 -0
  100. data/test/progit/es/01-introduction/01-chapter1.markdown +262 -0
  101. data/test/progit/es/02-git-basics/01-chapter2.markdown +1165 -0
  102. data/test/progit/es/03-git-branching/01-chapter3.markdown +598 -0
  103. data/test/progit/es/04-git-server/01-chapter4.markdown +707 -0
  104. data/test/progit/es/05-distributed-git/01-chapter5.markdown +890 -0
  105. data/test/progit/es/06-git-tools/01-chapter6.markdown +1113 -0
  106. data/test/progit/es/07-customizing-git/01-chapter7.markdown +875 -0
  107. data/test/progit/es/08-git-and-other-scms/01-chapter8.markdown +686 -0
  108. data/test/progit/es/09-git-internals/01-chapter9.markdown +976 -0
  109. data/test/progit/es/NOTES +29 -0
  110. data/test/progit/es/README +3 -0
  111. data/test/progit/es/glosario-Benzirpi.txt +27 -0
  112. data/test/progit/es/omegat-Benzirpi.tmx +29075 -0
  113. data/test/progit/fa/01-introduction/01-chapter1.markdown +262 -0
  114. data/test/progit/fa/03-git-branching/01-chapter3.markdown +608 -0
  115. data/test/progit/fa/04-git-server/01-chapter4.markdown +872 -0
  116. data/test/progit/fa/NOTES.en-fa.md +143 -0
  117. data/test/progit/fa/README.md +7 -0
  118. data/test/progit/fi/01-introduction/01-chapter1.markdown +259 -0
  119. data/test/progit/fi/02-git-basics/01-chapter2.markdown +1171 -0
  120. data/test/progit/fi/NOTES +5 -0
  121. data/test/progit/figures-dia/fig0101.dia +617 -0
  122. data/test/progit/figures-dia/fig0102.dia +921 -0
  123. data/test/progit/figures-dia/fig0103.dia +1468 -0
  124. data/test/progit/figures-dia/fig0104.dia +1432 -0
  125. data/test/progit/figures-dia/fig0105.dia +1924 -0
  126. data/test/progit/figures-dia/fig0106.dia +562 -0
  127. data/test/progit/figures-dia/fig0201.dia +774 -0
  128. data/test/progit/figures-dia/fig0301.dia +2006 -0
  129. data/test/progit/figures-dia/fig0302.dia +2148 -0
  130. data/test/progit/figures-dia/fig0303.dia +719 -0
  131. data/test/progit/figures-dia/fig0304.dia +525 -0
  132. data/test/progit/figures-dia/fig0305.dia +622 -0
  133. data/test/progit/figures-dia/fig0306.dia +622 -0
  134. data/test/progit/figures-dia/fig0307.dia +719 -0
  135. data/test/progit/figures-dia/fig0308.dia +734 -0
  136. data/test/progit/figures-dia/fig0309.dia +831 -0
  137. data/test/progit/figures-dia/fig0310.dia +412 -0
  138. data/test/progit/figures-dia/fig0311.dia +493 -0
  139. data/test/progit/figures-dia/fig0312.dia +596 -0
  140. data/test/progit/figures-dia/fig0313.dia +774 -0
  141. data/test/progit/figures-dia/fig0314.dia +846 -0
  142. data/test/progit/figures-dia/fig0315.dia +787 -0
  143. data/test/progit/figures-dia/fig0316.dia +1078 -0
  144. data/test/progit/figures-dia/fig0317.dia +881 -0
  145. data/test/progit/figures-dia/fig0318.dia +968 -0
  146. data/test/progit/figures-dia/fig0319.dia +957 -0
  147. data/test/progit/figures-dia/fig0320.dia +1637 -0
  148. data/test/progit/figures-dia/fig0321.dia +1494 -0
  149. data/test/progit/figures-dia/fig0322.dia +1142 -0
  150. data/test/progit/figures-dia/fig0323.dia +1377 -0
  151. data/test/progit/figures-dia/fig0324.dia +1603 -0
  152. data/test/progit/figures-dia/fig0325.dia +2003 -0
  153. data/test/progit/figures-dia/fig0326.dia +2013 -0
  154. data/test/progit/figures-dia/fig0327.dia +687 -0
  155. data/test/progit/figures-dia/fig0328.dia +814 -0
  156. data/test/progit/figures-dia/fig0329.dia +793 -0
  157. data/test/progit/figures-dia/fig0330.dia +693 -0
  158. data/test/progit/figures-dia/fig0331.dia +1159 -0
  159. data/test/progit/figures-dia/fig0332.dia +1362 -0
  160. data/test/progit/figures-dia/fig0333.dia +1165 -0
  161. data/test/progit/figures-dia/fig0334.dia +1450 -0
  162. data/test/progit/figures-dia/fig0335.dia +994 -0
  163. data/test/progit/figures-dia/fig0336.dia +786 -0
  164. data/test/progit/figures-dia/fig0337.dia +1546 -0
  165. data/test/progit/figures-dia/fig0338.dia +1755 -0
  166. data/test/progit/figures-dia/fig0339.dia +1882 -0
  167. data/test/progit/figures-dia/fig0501.dia +456 -0
  168. data/test/progit/figures-dia/fig0502.dia +956 -0
  169. data/test/progit/figures-dia/fig0503.dia +915 -0
  170. data/test/progit/figures-dia/fig0504.dia +620 -0
  171. data/test/progit/figures-dia/fig0505.dia +744 -0
  172. data/test/progit/figures-dia/fig0506.dia +747 -0
  173. data/test/progit/figures-dia/fig0507.dia +895 -0
  174. data/test/progit/figures-dia/fig0508.dia +1122 -0
  175. data/test/progit/figures-dia/fig0509.dia +1243 -0
  176. data/test/progit/figures-dia/fig0510.dia +1240 -0
  177. data/test/progit/figures-dia/fig0511.dia +1201 -0
  178. data/test/progit/figures-dia/fig0512.dia +801 -0
  179. data/test/progit/figures-dia/fig0513.dia +1387 -0
  180. data/test/progit/figures-dia/fig0514.dia +1568 -0
  181. data/test/progit/figures-dia/fig0515.dia +1721 -0
  182. data/test/progit/figures-dia/fig0516.dia +997 -0
  183. data/test/progit/figures-dia/fig0517.dia +994 -0
  184. data/test/progit/figures-dia/fig0518.dia +1145 -0
  185. data/test/progit/figures-dia/fig0519.dia +992 -0
  186. data/test/progit/figures-dia/fig0520.dia +1240 -0
  187. data/test/progit/figures-dia/fig0521.dia +801 -0
  188. data/test/progit/figures-dia/fig0522.dia +922 -0
  189. data/test/progit/figures-dia/fig0523.dia +922 -0
  190. data/test/progit/figures-dia/fig0524.dia +1828 -0
  191. data/test/progit/figures-dia/fig0525.dia +2685 -0
  192. data/test/progit/figures-dia/fig0526.dia +717 -0
  193. data/test/progit/figures-dia/fig0527.dia +856 -0
  194. data/test/progit/figures-dia/fig0601.dia +790 -0
  195. data/test/progit/figures-dia/fig0702.dia +795 -0
  196. data/test/progit/figures-dia/fig0703.dia +795 -0
  197. data/test/progit/figures-dia/fig0901.dia +669 -0
  198. data/test/progit/figures-dia/fig0902.dia +834 -0
  199. data/test/progit/figures-dia/fig0903.dia +1483 -0
  200. data/test/progit/figures-dia/fig0904.dia +1728 -0
  201. data/test/progit/figures-dia/makeimages +25 -0
  202. data/test/progit/figures-source/progit.graffle +123108 -0
  203. data/test/progit/figures/18333fig0101-tn.png +0 -0
  204. data/test/progit/figures/18333fig0102-tn.png +0 -0
  205. data/test/progit/figures/18333fig0103-tn.png +0 -0
  206. data/test/progit/figures/18333fig0104-tn.png +0 -0
  207. data/test/progit/figures/18333fig0105-tn.png +0 -0
  208. data/test/progit/figures/18333fig0106-tn.png +0 -0
  209. data/test/progit/figures/18333fig0107-tn.png +0 -0
  210. data/test/progit/figures/18333fig0201-tn.png +0 -0
  211. data/test/progit/figures/18333fig0202-tn.png +0 -0
  212. data/test/progit/figures/18333fig0301-tn.png +0 -0
  213. data/test/progit/figures/18333fig0302-tn.png +0 -0
  214. data/test/progit/figures/18333fig0303-tn.png +0 -0
  215. data/test/progit/figures/18333fig0304-tn.png +0 -0
  216. data/test/progit/figures/18333fig0305-tn.png +0 -0
  217. data/test/progit/figures/18333fig0306-tn.png +0 -0
  218. data/test/progit/figures/18333fig0307-tn.png +0 -0
  219. data/test/progit/figures/18333fig0308-tn.png +0 -0
  220. data/test/progit/figures/18333fig0309-tn.png +0 -0
  221. data/test/progit/figures/18333fig0310-tn.png +0 -0
  222. data/test/progit/figures/18333fig0311-tn.png +0 -0
  223. data/test/progit/figures/18333fig0312-tn.png +0 -0
  224. data/test/progit/figures/18333fig0313-tn.png +0 -0
  225. data/test/progit/figures/18333fig0314-tn.png +0 -0
  226. data/test/progit/figures/18333fig0315-tn.png +0 -0
  227. data/test/progit/figures/18333fig0316-tn.png +0 -0
  228. data/test/progit/figures/18333fig0317-tn.png +0 -0
  229. data/test/progit/figures/18333fig0318-tn.png +0 -0
  230. data/test/progit/figures/18333fig0319-tn.png +0 -0
  231. data/test/progit/figures/18333fig0320-tn.png +0 -0
  232. data/test/progit/figures/18333fig0321-tn.png +0 -0
  233. data/test/progit/figures/18333fig0322-tn.png +0 -0
  234. data/test/progit/figures/18333fig0323-tn.png +0 -0
  235. data/test/progit/figures/18333fig0324-tn.png +0 -0
  236. data/test/progit/figures/18333fig0325-tn.png +0 -0
  237. data/test/progit/figures/18333fig0326-tn.png +0 -0
  238. data/test/progit/figures/18333fig0327-tn.png +0 -0
  239. data/test/progit/figures/18333fig0328-tn.png +0 -0
  240. data/test/progit/figures/18333fig0329-tn.png +0 -0
  241. data/test/progit/figures/18333fig0330-tn.png +0 -0
  242. data/test/progit/figures/18333fig0331-tn.png +0 -0
  243. data/test/progit/figures/18333fig0332-tn.png +0 -0
  244. data/test/progit/figures/18333fig0333-tn.png +0 -0
  245. data/test/progit/figures/18333fig0334-tn.png +0 -0
  246. data/test/progit/figures/18333fig0335-tn.png +0 -0
  247. data/test/progit/figures/18333fig0336-tn.png +0 -0
  248. data/test/progit/figures/18333fig0337-tn.png +0 -0
  249. data/test/progit/figures/18333fig0338-tn.png +0 -0
  250. data/test/progit/figures/18333fig0339-tn.png +0 -0
  251. data/test/progit/figures/18333fig0401-tn.png +0 -0
  252. data/test/progit/figures/18333fig0402-tn.png +0 -0
  253. data/test/progit/figures/18333fig0403-tn.png +0 -0
  254. data/test/progit/figures/18333fig0404-tn.png +0 -0
  255. data/test/progit/figures/18333fig0405-tn.png +0 -0
  256. data/test/progit/figures/18333fig0406-tn.png +0 -0
  257. data/test/progit/figures/18333fig0407-tn.png +0 -0
  258. data/test/progit/figures/18333fig0408-tn.png +0 -0
  259. data/test/progit/figures/18333fig0409-tn.png +0 -0
  260. data/test/progit/figures/18333fig0410-tn.png +0 -0
  261. data/test/progit/figures/18333fig0411-tn.png +0 -0
  262. data/test/progit/figures/18333fig0412-tn.png +0 -0
  263. data/test/progit/figures/18333fig0413-tn.png +0 -0
  264. data/test/progit/figures/18333fig0414-tn.png +0 -0
  265. data/test/progit/figures/18333fig0415-tn.png +0 -0
  266. data/test/progit/figures/18333fig0501-tn.png +0 -0
  267. data/test/progit/figures/18333fig0502-tn.png +0 -0
  268. data/test/progit/figures/18333fig0503-tn.png +0 -0
  269. data/test/progit/figures/18333fig0504-tn.png +0 -0
  270. data/test/progit/figures/18333fig0505-tn.png +0 -0
  271. data/test/progit/figures/18333fig0506-tn.png +0 -0
  272. data/test/progit/figures/18333fig0507-tn.png +0 -0
  273. data/test/progit/figures/18333fig0508-tn.png +0 -0
  274. data/test/progit/figures/18333fig0509-tn.png +0 -0
  275. data/test/progit/figures/18333fig0510-tn.png +0 -0
  276. data/test/progit/figures/18333fig0511-tn.png +0 -0
  277. data/test/progit/figures/18333fig0512-tn.png +0 -0
  278. data/test/progit/figures/18333fig0513-tn.png +0 -0
  279. data/test/progit/figures/18333fig0514-tn.png +0 -0
  280. data/test/progit/figures/18333fig0515-tn.png +0 -0
  281. data/test/progit/figures/18333fig0516-tn.png +0 -0
  282. data/test/progit/figures/18333fig0517-tn.png +0 -0
  283. data/test/progit/figures/18333fig0518-tn.png +0 -0
  284. data/test/progit/figures/18333fig0519-tn.png +0 -0
  285. data/test/progit/figures/18333fig0520-tn.png +0 -0
  286. data/test/progit/figures/18333fig0521-tn.png +0 -0
  287. data/test/progit/figures/18333fig0522-tn.png +0 -0
  288. data/test/progit/figures/18333fig0523-tn.png +0 -0
  289. data/test/progit/figures/18333fig0524-tn.png +0 -0
  290. data/test/progit/figures/18333fig0525-tn.png +0 -0
  291. data/test/progit/figures/18333fig0526-tn.png +0 -0
  292. data/test/progit/figures/18333fig0527-tn.png +0 -0
  293. data/test/progit/figures/18333fig0601-tn.png +0 -0
  294. data/test/progit/figures/18333fig0701-tn.png +0 -0
  295. data/test/progit/figures/18333fig0702-tn.png +0 -0
  296. data/test/progit/figures/18333fig0703-tn.png +0 -0
  297. data/test/progit/figures/18333fig0901-tn.png +0 -0
  298. data/test/progit/figures/18333fig0902-tn.png +0 -0
  299. data/test/progit/figures/18333fig0903-tn.png +0 -0
  300. data/test/progit/figures/18333fig0904-tn.png +0 -0
  301. data/test/progit/fr/01-introduction/01-chapter1.markdown +371 -0
  302. data/test/progit/fr/02-git-basics/01-chapter2.markdown +1378 -0
  303. data/test/progit/fr/03-git-branching/01-chapter3.markdown +781 -0
  304. data/test/progit/fr/04-git-server/01-chapter4.markdown +1141 -0
  305. data/test/progit/fr/05-distributed-git/01-chapter5.markdown +1163 -0
  306. data/test/progit/fr/06-git-tools/01-chapter6.markdown +1356 -0
  307. data/test/progit/fr/07-customizing-git/01-chapter7.markdown +1200 -0
  308. data/test/progit/fr/08-git-and-other-scms/01-chapter8.markdown +832 -0
  309. data/test/progit/fr/09-git-internals/01-chapter9.markdown +1228 -0
  310. data/test/progit/fr/NOTES.fr-fr.markdown +1 -0
  311. data/test/progit/fr/NOTES.fr-fr.md +127 -0
  312. data/test/progit/fr/README.md +43 -0
  313. data/test/progit/fr/glossaire-git.adoc +108 -0
  314. data/test/progit/hi/01-introduction/01-chapter1.markdown +7 -0
  315. data/test/progit/hu/01-introduction/01-chapter1.markdown +257 -0
  316. data/test/progit/id/01-introduction/01-chapter1.markdown +257 -0
  317. data/test/progit/id/02-git-basics/01-chapter2.markdown +1127 -0
  318. data/test/progit/id/03-git-branching/01-chapter3.markdown +598 -0
  319. data/test/progit/it/01-introduction/01-chapter1.markdown +263 -0
  320. data/test/progit/it/02-git-basics/01-chapter2.markdown +1227 -0
  321. data/test/progit/it/03-git-branching/01-chapter3.markdown +598 -0
  322. data/test/progit/it/04-git-server/01-chapter4.markdown +864 -0
  323. data/test/progit/it/05-distributed-git/01-chapter5.markdown +897 -0
  324. data/test/progit/it/06-git-tools/01-chapter6.markdown +1144 -0
  325. data/test/progit/it/07-customizing-git/01-chapter7.markdown +606 -0
  326. data/test/progit/it/08-git-and-other-scms/01-chapter8.markdown +707 -0
  327. data/test/progit/it/09-git-internals/01-chapter9.markdown +1000 -0
  328. data/test/progit/ja/01-introduction/01-chapter1.markdown +260 -0
  329. data/test/progit/ja/02-git-basics/01-chapter2.markdown +1221 -0
  330. data/test/progit/ja/03-git-branching/01-chapter3.markdown +604 -0
  331. data/test/progit/ja/04-git-server/01-chapter4.markdown +863 -0
  332. data/test/progit/ja/05-distributed-git/01-chapter5.markdown +908 -0
  333. data/test/progit/ja/06-git-tools/01-chapter6.markdown +1133 -0
  334. data/test/progit/ja/07-customizing-git/01-chapter7.markdown +936 -0
  335. data/test/progit/ja/08-git-and-other-scms/01-chapter8.markdown +690 -0
  336. data/test/progit/ja/09-git-internals/01-chapter9.markdown +984 -0
  337. data/test/progit/ja/README.md +58 -0
  338. data/test/progit/ja/translation glossaries.txt +33 -0
  339. data/test/progit/ko/01-introduction/01-chapter1.markdown +258 -0
  340. data/test/progit/ko/02-git-basics/01-chapter2.markdown +1181 -0
  341. data/test/progit/ko/03-git-branching/01-chapter3.markdown +612 -0
  342. data/test/progit/ko/04-git-server/01-chapter4.markdown +867 -0
  343. data/test/progit/ko/05-distributed-git/01-chapter5.markdown +913 -0
  344. data/test/progit/ko/06-git-tools/01-chapter6.markdown +1142 -0
  345. data/test/progit/ko/07-customizing-git/01-chapter7.markdown +935 -0
  346. data/test/progit/ko/08-git-and-other-scms/01-chapter8.markdown +688 -0
  347. data/test/progit/ko/09-git-internals/01-chapter9.markdown +976 -0
  348. data/test/progit/ko/README.md +75 -0
  349. data/test/progit/ko/translation_guide.txt +65 -0
  350. data/test/progit/latex/README +27 -0
  351. data/test/progit/latex/config.yml +144 -0
  352. data/test/progit/latex/makepdf +207 -0
  353. data/test/progit/latex/template.tex +155 -0
  354. data/test/progit/makeebooks +125 -0
  355. data/test/progit/makepdfs +47 -0
  356. data/test/progit/mk/01-introduction/01-chapter1.markdown +258 -0
  357. data/test/progit/mk/02-git-basics/01-chapter2.markdown +1125 -0
  358. data/test/progit/mk/03-git-branching/01-chapter3.markdown +598 -0
  359. data/test/progit/mk/05-distributed-git/01-chapter5.markdown +897 -0
  360. data/test/progit/nl/01-introduction/01-chapter1.markdown +296 -0
  361. data/test/progit/nl/02-git-basics/01-chapter2.markdown +1253 -0
  362. data/test/progit/nl/03-git-branching/01-chapter3.markdown +642 -0
  363. data/test/progit/nl/04-git-server/01-chapter4.markdown +902 -0
  364. data/test/progit/nl/05-distributed-git/01-chapter5.markdown +953 -0
  365. data/test/progit/nl/06-git-tools/01-chapter6.markdown +1177 -0
  366. data/test/progit/nl/07-customizing-git/01-chapter7.markdown +974 -0
  367. data/test/progit/nl/08-git-and-other-scms/01-chapter8.markdown +725 -0
  368. data/test/progit/nl/09-git-internals/01-chapter9.markdown +1013 -0
  369. data/test/progit/no-nb/01-introduction/01-chapter1.markdown +261 -0
  370. data/test/progit/no-nb/02-git-basics/01-chapter2.markdown +1225 -0
  371. data/test/progit/no-nb/03-git-branching/01-chapter3.markdown +606 -0
  372. data/test/progit/no-nb/04-git-server/01-chapter4.markdown +867 -0
  373. data/test/progit/no-nb/05-distributed-git/01-chapter5.markdown +914 -0
  374. data/test/progit/no-nb/06-git-tools/01-chapter6.markdown +1144 -0
  375. data/test/progit/no-nb/07-customizing-git/01-chapter7.markdown +936 -0
  376. data/test/progit/no-nb/08-git-and-other-scms/01-chapter8.markdown +689 -0
  377. data/test/progit/no-nb/09-git-internals/01-chapter9.markdown +977 -0
  378. data/test/progit/no-nb/README +2 -0
  379. data/test/progit/pl/01-introduction/01-chapter1.markdown +257 -0
  380. data/test/progit/pl/02-git-basics/02-chapter2.markdown +1128 -0
  381. data/test/progit/pl/03-git-branching/01-chapter3.markdown +598 -0
  382. data/test/progit/pl/04-git-server/01-chapter4.markdown +897 -0
  383. data/test/progit/pl/05-distributed-git/01-chapter5.markdown +1278 -0
  384. data/test/progit/pl/06-git-tools/01-chapter6.markdown +1550 -0
  385. data/test/progit/pl/07-customizing-git/01-chapter7.markdown +1058 -0
  386. data/test/progit/pl/08-git-and-other-scms/01-chapter8.markdown +948 -0
  387. data/test/progit/pl/09-git-internals/01-chapter9.markdown +1382 -0
  388. data/test/progit/pl/translation-guidelines.txt +70 -0
  389. data/test/progit/pt-br/01-introduction/01-chapter1.markdown +256 -0
  390. data/test/progit/pt-br/02-git-basics/01-chapter2.markdown +1127 -0
  391. data/test/progit/pt-br/03-git-branching/01-chapter3.markdown +596 -0
  392. data/test/progit/pt-br/04-git-server/01-chapter4.markdown +888 -0
  393. data/test/progit/pt-br/05-distributed-git/01-chapter5.markdown +896 -0
  394. data/test/progit/pt-br/06-git-tools/01-chapter6.markdown +1122 -0
  395. data/test/progit/pt-br/07-customizing-git/01-chapter7.markdown +932 -0
  396. data/test/progit/pt-br/08-git-and-other-scms/01-chapter8.markdown +691 -0
  397. data/test/progit/pt-br/09-git-internals/01-chapter9.markdown +978 -0
  398. data/test/progit/pt-br/figures-dia/fig0101.dia +617 -0
  399. data/test/progit/pt-br/figures-dia/fig0102.dia +921 -0
  400. data/test/progit/pt-br/figures-dia/fig0103.dia +1468 -0
  401. data/test/progit/pt-br/figures-dia/fig0104.dia +1432 -0
  402. data/test/progit/pt-br/figures-dia/fig0105.dia +1924 -0
  403. data/test/progit/pt-br/figures-dia/fig0106.dia +562 -0
  404. data/test/progit/pt-br/figures-dia/fig0201.dia +776 -0
  405. data/test/progit/pt-br/figures-dia/fig0301.dia +2006 -0
  406. data/test/progit/pt-br/figures-dia/fig0302.dia +2148 -0
  407. data/test/progit/pt-br/figures-dia/fig0316.dia +1079 -0
  408. data/test/progit/pt-br/figures-dia/fig0322.dia +1142 -0
  409. data/test/progit/pt-br/figures-dia/fig0323.dia +1407 -0
  410. data/test/progit/pt-br/figures-dia/fig0324.dia +1603 -0
  411. data/test/progit/pt-br/figures-dia/fig0325.dia +2003 -0
  412. data/test/progit/pt-br/figures-dia/fig0326.dia +2013 -0
  413. data/test/progit/pt-br/figures-dia/fig0336.dia +786 -0
  414. data/test/progit/pt-br/figures-dia/fig0337.dia +1546 -0
  415. data/test/progit/pt-br/figures-dia/fig0338.dia +1755 -0
  416. data/test/progit/pt-br/figures-dia/fig0339.dia +1882 -0
  417. data/test/progit/pt-br/figures-dia/fig0501.dia +456 -0
  418. data/test/progit/pt-br/figures-dia/fig0502.dia +965 -0
  419. data/test/progit/pt-br/figures-dia/fig0503.dia +914 -0
  420. data/test/progit/pt-br/figures-dia/fig0511.dia +1201 -0
  421. data/test/progit/pt-br/figures-dia/fig0515.dia +1721 -0
  422. data/test/progit/pt-br/figures-dia/fig0702.dia +795 -0
  423. data/test/progit/pt-br/figures-dia/fig0703.dia +795 -0
  424. data/test/progit/pt-br/figures-dia/fig0901.dia +669 -0
  425. data/test/progit/pt-br/figures-dia/fig0902.dia +834 -0
  426. data/test/progit/pt-br/figures-dia/fig0903.dia +1483 -0
  427. data/test/progit/pt-br/figures-dia/fig0904.dia +1728 -0
  428. data/test/progit/ro/01-introduction/01-chapter1.markdown +257 -0
  429. data/test/progit/ru/01-introduction/01-chapter1.markdown +259 -0
  430. data/test/progit/ru/02-git-basics/01-chapter2.markdown +1155 -0
  431. data/test/progit/ru/03-git-branching/01-chapter3.markdown +598 -0
  432. data/test/progit/ru/04-git-server/01-chapter4.markdown +854 -0
  433. data/test/progit/ru/05-distributed-git/01-chapter5.markdown +897 -0
  434. data/test/progit/ru/06-git-tools/01-chapter6.markdown +1126 -0
  435. data/test/progit/ru/07-customizing-git/01-chapter7.markdown +938 -0
  436. data/test/progit/ru/08-git-and-other-scms/01-chapter8.markdown +691 -0
  437. data/test/progit/ru/09-git-internals/01-chapter9.markdown +977 -0
  438. data/test/progit/ru/Glossary +38 -0
  439. data/test/progit/ru/README +12 -0
  440. data/test/progit/ru/figures-dia/fig0101.dia +647 -0
  441. data/test/progit/ru/figures-dia/fig0102.dia +1009 -0
  442. data/test/progit/ru/figures-dia/fig0103.dia +1468 -0
  443. data/test/progit/ru/figures-dia/fig0104.dia +1432 -0
  444. data/test/progit/ru/figures-dia/fig0105.dia +1924 -0
  445. data/test/progit/ru/figures-dia/fig0106.dia +561 -0
  446. data/test/progit/ru/figures-dia/fig0201.dia +774 -0
  447. data/test/progit/ru/figures-dia/fig0322.dia +1182 -0
  448. data/test/progit/ru/figures-dia/fig0323.dia +1457 -0
  449. data/test/progit/ru/figures-dia/fig0324.dia +1698 -0
  450. data/test/progit/ru/figures-dia/fig0325.dia +2101 -0
  451. data/test/progit/ru/figures-dia/fig0326.dia +2111 -0
  452. data/test/progit/ru/figures-dia/fig0336.dia +786 -0
  453. data/test/progit/ru/figures-dia/fig0337.dia +1546 -0
  454. data/test/progit/ru/figures-dia/fig0338.dia +1755 -0
  455. data/test/progit/ru/figures-dia/fig0339.dia +1882 -0
  456. data/test/progit/ru/figures-dia/fig0501.dia +477 -0
  457. data/test/progit/ru/figures-dia/fig0502.dia +1063 -0
  458. data/test/progit/ru/figures-dia/fig0503.dia +915 -0
  459. data/test/progit/ru/figures-dia/fig0511.dia +1201 -0
  460. data/test/progit/ru/figures-dia/fig0515.dia +1741 -0
  461. data/test/progit/ru/figures-dia/fig0702.dia +851 -0
  462. data/test/progit/ru/figures-dia/fig0703.dia +851 -0
  463. data/test/progit/sr/01-introduction/01-chapter1.markdown +257 -0
  464. data/test/progit/summary.rb +29 -0
  465. data/test/progit/th/01-introduction/01-chapter1.markdown +257 -0
  466. data/test/progit/th/02-git-basics/01-chapter2.markdown +1126 -0
  467. data/test/progit/th/README.md +47 -0
  468. data/test/progit/tr/01-introduction/01-chapter1.markdown +258 -0
  469. data/test/progit/tr/02-git-basics/01-chapter2.markdown +1129 -0
  470. data/test/progit/tr/03-git-branching/01-chapter3.markdown +598 -0
  471. data/test/progit/tr/04-git-server/01-chapter4.markdown +73 -0
  472. data/test/progit/tr/05-distributed-git/01-chapter5.markdown +215 -0
  473. data/test/progit/uk/01-introduction/01-chapter1.markdown +522 -0
  474. data/test/progit/vi/01-introduction/01-chapter1.markdown +259 -0
  475. data/test/progit/vi/02-git-basics/01-chapter2.markdown +1172 -0
  476. data/test/progit/vi/03-git-branching/01-chapter3.markdown +598 -0
  477. data/test/progit/zh-tw/01-introduction/01-chapter1.markdown +259 -0
  478. data/test/progit/zh-tw/02-git-basics/01-chapter2.markdown +1183 -0
  479. data/test/progit/zh-tw/03-git-branching/01-chapter3.markdown +604 -0
  480. data/test/progit/zh-tw/04-git-server/01-chapter4.markdown +866 -0
  481. data/test/progit/zh-tw/05-distributed-git/01-chapter5.markdown +912 -0
  482. data/test/progit/zh-tw/06-git-tools/01-chapter6.markdown +1139 -0
  483. data/test/progit/zh-tw/07-customizing-git/01-chapter7.markdown +932 -0
  484. data/test/progit/zh-tw/08-git-and-other-scms/01-chapter8.markdown +689 -0
  485. data/test/progit/zh-tw/09-git-internals/01-chapter9.markdown +977 -0
  486. data/test/progit/zh/01-introduction/01-chapter1.markdown +259 -0
  487. data/test/progit/zh/02-git-basics/01-chapter2.markdown +1177 -0
  488. data/test/progit/zh/03-git-branching/01-chapter3.markdown +604 -0
  489. data/test/progit/zh/04-git-server/01-chapter4.markdown +866 -0
  490. data/test/progit/zh/05-distributed-git/01-chapter5.markdown +912 -0
  491. data/test/progit/zh/06-git-tools/01-chapter6.markdown +1125 -0
  492. data/test/progit/zh/07-customizing-git/01-chapter7.markdown +935 -0
  493. data/test/progit/zh/08-git-and-other-scms/01-chapter8.markdown +689 -0
  494. data/test/progit/zh/09-git-internals/01-chapter9.markdown +976 -0
  495. data/test/spec_tests.json +4382 -4070
  496. data/test/test_basics.rb +1 -1
  497. data/test/test_helper.rb +1 -0
  498. data/test/test_maliciousness.rb +4 -2
  499. data/test/test_pathological_inputs.rb +31 -30
  500. data/test/test_spec.rb +5 -4
  501. metadata +972 -4
@@ -0,0 +1,1124 @@
1
+ # مبادئ Git #
2
+
3
+ إذا كان هناك فصل واحد عليك قراءته لكي تبدأ بإستخدام Git، فعليك بهذا الفصل! يغطي هذا الفصل جميع الأوامر الأساسية التي عليك معرفتها لكي تتمكن من القيام بأغلب الأمور أثناء استخدامك لـ Git. في نهاية هذا الفصل يجب أن تكون قادراً على انشاء واعداد الـ repository لمشروعك وعلى تحديد الملفات التي ستتم متابعتها والتي ستترك، وعلى تهييئ التغييرات لعمل commit عليها. ستتعلم أيضاً كيف تعد Git لكي تتجاهل بعض أنواع الملفات، كيف تقوم بالتراجع عن الأخطاء التي سترتكبها بسرعة وبسهولة، كيف تتصفح تاريخ مشروعك وكيف تعرض التغيرات بين الـ commits، وكيف تنشر وتسحب (push & pull) التغيرات من الـ repositories البعيدة عنك.
4
+
5
+ ## الحصول على repository لمشروعك بـ Git ##
6
+
7
+ يمكنك انشاء مشروع بـ git بإحدى طريقتين. الأولى تكمن في أن تبدأ بناء على مشروع أسبق أو مجلد على سبيل المثال يحوي ملفات وأن تستورد مافيه الى مشروعك الجديد. أو أن تستنسخ repository بـ git جاهزة من مخدم ما.
8
+
9
+ ### انشاء Repository في مجلد موجود مسبقاً ###
10
+
11
+ للبد بمتابعة تغيرات مشروع مسبق لديك بـ git، عليك الذهاب الى مجلد مشروعك ثم كتابة:
12
+
13
+ $ git init
14
+
15
+ يقوم هذا بانشاء مجلد فرعية جديد تحت اسم .git يحوي جميع المعلومات والملفات المطلوبة - هيكل repository بـ git. حتى الآن، لن يتم متابعة أي تغيرات تحصل على مشروعك (انظر الفصل التاسع لمعلومات أخرى عن الملفات الموجودة في مجلد `.git` الذي أنشأته قبل قليل).
16
+
17
+ اذا أردت بمتابعة اصدارات الملفات الموجودة، يجب عليك البدء باخبار Git بهذه الملفات ومن ثم اجراء commit أولي. للقيام بهذا عليك استخدام أمر git add بالعدد الكافي بالملفات التي تريد، ومن ثم تتبعها أمر commit:
18
+
19
+ $ git add *.c
20
+ $ git add README
21
+ $ git commit –m 'initial project version'
22
+
23
+ سنقوم بشرح هذه الأوامر في الفقرة القادمة، ولكن، الآن أصبحت التغيرات في مشروعك تتم متابعتها و commit أولي.
24
+
25
+ ### استنساخ repository موجودة مسبقاً ###
26
+
27
+ للقيام باستنساخ repository بـ git موجودة مسبقاً - مشروع تريد المساهمة فيه على سبيل المثال - الأمر الذي ستحتاجه هو git clone. اذا كنت قد استخدمت أحد أنظمة إدارة الإصدارات الأخرى مثل Subversion مثلاً، ستلاحظ الإختلاف بين الأمر clone في git وأمر checkout. هناك فرق مهم، عندما تقوم git بعملية clone فإنك ستحصل على نسخة من كامل المعلومات تقريباً الموجودة على مخدم الـ repository. جميع إصدارات الملفات كلها في تاريخ حياة المشروع. أي، وبمعنى آخر، اذا حدث عطل أو ضرر ما لملفات المشروع الموجودة على المخدم الأساسي يمكنك استخدام أي واحدة من النسخ لاسترجاع المشروع للحالة التي كان عليها عند استنساخه (من الممكن أن تخسر بعض الروابط من طرف المخدم، ولكن جميع معلومات الإصدارات ستكون موجودة- انظر الفصل الرابع لمعلومات اخرى).
28
+
29
+
30
+ لاستنساخ repository يمكنك استخدام الأمر 'git clone [url]'. فعلى سبيل المثال، لكي تقوم باستنساخ مكتبة Git للغة Ruby والتي تدعى Grit، يمكنك القيام بالتالي:
31
+
32
+ $ git clone git://github.com/schacon/grit.git
33
+
34
+ سيقوم هذا بانشاء مجلد جديد باسم "grit"، وتجهيز مجلد '.git' في داخله، سيقوم أيضاً بسحب جميع المعلومات من الـ repository، ويجهز نسخة جاهزة لكي تعمل عليها لآخر نسخة. اذا دخلت على مجلد 'grit' الجديد ستجد جميع ملفات المشروع. يمكنك بالطبع استنساخ المشروع لمجلد بإسم آخر، إليك مثال لكيفية القيام بهذا:
35
+
36
+ $ git clone git://github.com/schacon/grit.git mygrit
37
+
38
+ سيقوم هذا الأمر بذات الأمر ولكن سيتم وضع المشروع بمجلد جديد باسم mygrit.
39
+
40
+ هناك عدد من البروتوكولات المختلفة التي يمكنك اسستعمالها لنقل المعلومات في git. المثال السابق يستعمل بروتوكول 'git://'، ولكن من الممكن أن تجد أيضاً استخداماً لـ 'http(s)://' أو 'user@server:/path.git'، والتي تستعمل بروتوكول SSH في النقل. في الفصل الرابع من الكتاب ستتعرف على الخيارات المتوفرة للتواصل مع الـ repository الخاصة بك وميزات ومساوئ كل منها.
41
+
42
+ ## تسجيل التعديلات في الـ repository ##
43
+ لديك repository أصلي ونسخة لتعمل عليها من ملفات المشروع. عليك أن تقوم ببعض التعديلات ثم تعمل commit لهذه التعديلات في repository الخاص بك في كل مرة يصل فيها المشروع إلى نقطة تود تسجيلها.
44
+
45
+ تذكر أنه كل ملف في مجلد العمل يمكن أن يكون في إحدى الحالتين فقط: مٌتَتَبّع tracked أو غير مٌتَتَبّع untracked. الملفات المٌتتبّعة هي ملفات كانت في أخر snapshot ويمكن إلغاء التعديلات عليها أو التعديل عليها أو وضعه في حالة staged (جاهز من أجل commit). الملفات غير المُتتبّعة هي كل الملفات الآخرى - أي ملف في مجلد العمل لم يكن موجوداً في آخر snapshot وليس معلماً بأنه staged. عندما تقوم باستنساخ repository جميع ملفاتك تكون بحالة متتبّعة tracked و غير معدلة unmodified لأنك قمت للتو بعمل check out ولم تقم بأي تعديل.
46
+
47
+ عندما تعدل الملفات، سيقوم git بتأشيرهم على أنهم modified، لأنك قمت بتغيرهم عن آخر commit. تقوم بعمل stage لهذه الملفات المعدلة ثم تقوم بعمل commit لجميع التغيرات في منطقة stage، وتتكرر العملية. يوضع الشكل 2-1 دورة العملية.
48
+
49
+ Insert 18333fig0201.png
50
+ الشكل 2-1. دورة حالة الملفات.
51
+
52
+ ### تفقد حالة ملفاتك ###
53
+
54
+ باستخدام الأمر git status يمكننا معرفة حالة الملفات لدينا. إذا قمت بتشغيل هذا الأمر مباشرة بعد قيامك بعمل clone يجب أن ترى شيئاً يشبه التالي:
55
+
56
+ $ git status
57
+ # On branch master
58
+ nothing to commit, working directory clean
59
+
60
+ وهذا يعني أنه لديك مجلد عمل نظيف - بمعنى آخر، لايوجد أي ملفات معدلة أو ملفات غير مُتتبّعة. كما أنّ هذا الأمر يخبرك بأي فرع branch أنت تعمل. حالياً، دائماً هو master، وهو الافتراضي؛ في الفصل المقبل سنمر على الأفرع و المرجعيات references بالتفصيل.
61
+
62
+ لنقل بأنك قمت بإضافة ملف جديد على مشروعك، وليكن ملف README بسيط. إذا لم يكن الملف موجوداً مسبقاً، وقمت بتنفيذ الأمر `git status` سترى الملف غير مُتتبّعاً كما يلي:
63
+
64
+ $ vim README
65
+ $ git status
66
+ # On branch master
67
+ # Untracked files:
68
+ # (use "git add <file>..." to include in what will be committed)
69
+ #
70
+ # README
71
+ nothing added to commit but untracked files present (use "git add" to track)
72
+
73
+ يمكنك ملاحظة أنّ ملفك الجديد README غير مُتتبّع، فهو تحت تبويب "untracked files" في خرج الأمر. ويعني ذلك أنّ git يرى ملفاً جديداً على commit السابقة؛ علماً أنّ git لن يقوم بإضافة هذا الملف إلى الملفات المتتبعة إلا إذا قمت بطلب ذلك بشكل مباشر، والهدف من ذلك من أجل حماية المشروع من الضم الخاطئ لملفات binary أو أي ملفات لا تود بإضافتها. إلاّ أنّك ترغب في إضافة README إلى الملفات المتتبّعة. وسنقوم بذلك حالاً.
74
+
75
+ ### تتبع الملفات الجديدة ###
76
+
77
+ للقيام بتتبع ملف جديد عليه استخدام الأمر `git add` . مثلاً لنقم بتتبع الملف الجديد README:
78
+
79
+ $ git add README
80
+
81
+ إذا قمنا بتنفيذ الأمر `git status` مرة أخرى سنلاحظ أن الملف README أصبح متتبعاً وجاهزاً staged للقيام بعملية commit:
82
+
83
+ $ git status
84
+ # On branch master
85
+ # Changes to be committed:
86
+ # (use "git reset HEAD <file>..." to unstage)
87
+ #
88
+ # new file: README
89
+ #
90
+
91
+ نستطيع معرفة بأن الملف staged من خلال ملاحظته تحت بند "changes to be comitted". إذا قمت بعمل commit في هذه اللحظة، سيقوم git بإضافة النسخة الحالية من الملف إلى snapshot. تذكر عندما قمنا بعمل git init سابقاً، ثم قمنا بإضافة الملفات عن طريق git add، كان ذلك للقيام ببدء تتبع الملفات في مجلد المشروع. يقبل الأمر git add مسار لملف أو لمجلد؛ فإذا كان المسار لمجلد سيقوم git بإضافة جميع الملفات والمجلدات ضمنه بشكل تعاودي recursively.
92
+
93
+ ### تجهيز الملفات المعدلة ###
94
+
95
+ لنقم بالتعديل على ملف قمنا بإضافته سابقاً. إذا قمنا مثلاً بالتعديل على ملف متتبع مسبقاً يدعى `benchmarks.rb` وقمنا بتنفيذ الأمر git status، سيكون الخرج مشابهاً للخرج التالي:
96
+
97
+ $ git status
98
+ # On branch master
99
+ # Changes to be committed:
100
+ # (use "git reset HEAD <file>..." to unstage)
101
+ #
102
+ # new file: README
103
+ #
104
+ # Changes not staged for commit:
105
+ # (use "git add <file>..." to update what will be committed)
106
+ #
107
+ # modified: benchmarks.rb
108
+ #
109
+
110
+ يظهر الملف benchmarks.rb تحت بند "changes not staged for commit" وهذا يعني أن الملف المُتتبّع قد خضع لعملية تعديل لكنه لم يخضع للتجهيز من أجل commit. للقيام بتجهيزه (أو تأشيره للإضافة إلى commit الجديد) يجب علينا تنفيذ الأمر `git add` (لاحظ بأنّه أمر متعدد الوظائف - نستطيع استخدامه لتتبع الملفات الجديدة، تجهيز الملفات من أجل commit، والقيام بأمور أخرى مثل حل الاعتراضات في حال القيام بدمج merge). لنقم بتنفيذ git add الآن لوضع benchmarks.rb بحالة staged، ومن ثم لنقم بتنفيذ الأمر git status لنرى ما الذي قد تغيّر:
111
+
112
+ $ git add benchmarks.rb
113
+ $ git status
114
+ # On branch master
115
+ # Changes to be committed:
116
+ # (use "git reset HEAD <file>..." to unstage)
117
+ #
118
+ # new file: README
119
+ # modified: benchmarks.rb
120
+ #
121
+
122
+ كلا الملفين الآن جاهز للإدخال بعملية commit المقبلة. في هذه النقطة، لنفرض أنك تود القيام بتعديل على ملف benchmarks.rb قبل القيام بعملية commit، ستقوم بفتح الملف والتعديل عليه وأنك جاهز للقيام بعملية commit. لكن قبل ذلك، دعنا نقوم بتنفيذ الأمر git status مرة إضافية:
123
+
124
+ $ vim benchmarks.rb
125
+ $ git status
126
+ # On branch master
127
+ # Changes to be committed:
128
+ # (use "git reset HEAD <file>..." to unstage)
129
+ #
130
+ # new file: README
131
+ # modified: benchmarks.rb
132
+ #
133
+ # Changes not staged for commit:
134
+ # (use "git add <file>..." to update what will be committed)
135
+ #
136
+ # modified: benchmarks.rb
137
+ #
138
+
139
+ ما الذي يحصل؟ كيف أصبح benchmarks.rb موجوداً تحت التبويبين staged و unstaged؟ لقد اتضح لنا أنّ git يقوم بتجهيز الملف على حالته عند قيامك بتنفيذ الأمر git add. إذا قمت بعمل commit الآن، ستكون نسخة benchmarks.rb كما كانت عند قيامك بتنفيذ الأمر git add وليس النسخة الجديدة التي حصلنا عليها بعد قيامنا بتعديل الملف. لذا إذا قمنا بتعديل ملف قبل قيامنا بتنفيذ git add، وقبل القيام بعملية commit، علينا تجهيز الملف مرة أخرى لعملية commit، وذلك بتنفيذ الأمر git add مرة جديدة:
140
+
141
+ $ git add benchmarks.rb
142
+ $ git status
143
+ # On branch master
144
+ # Changes to be committed:
145
+ # (use "git reset HEAD <file>..." to unstage)
146
+ #
147
+ # new file: README
148
+ # modified: benchmarks.rb
149
+ #
150
+
151
+ ### تجاهل الملفات ###
152
+
153
+ غالباً ما تود من git تجاهل صنف من الملفات بحث لا يقوم بإضافتها تلقائياً أو لا يظهرها بأنّها غير متتبعة. تكون هذه الملفات عادة ملفات مولدة بشكل تلقائي مثل ملفات log و الملفات الوسيطة التي تولدها أدوات التطوير لديك. في مثل هذه الحالات/ يمكن إنشاء ملف .gitignore يحوي على أنماط لأسماء الملفات التي نرغب بتجاهلها. هذا مثال عمّا قد يحتويه ملف .gitignore:
154
+
155
+ $ cat .gitignore
156
+ *.[oa]
157
+ *~
158
+
159
+ أول سطر يقوم بتوجيه git إلى تجاهل أي ملفات ذات لواحق من النوع o أو a - ملفات الكائنات وملفات الأرشيف وهي ملفات وسيطة تولدها أدوات بناء الكود عادة. السطر الثاني يوجه git إلى تجاهل أي ملفات تنتهي بالرمز (~) والتي تكون ملفات مؤقتة عادةً تستخدمها بعض برامج تحرير الكود. قد ترغب أيضاً بإضافة مجلدات log و tmp أو pid؛ أو حتى ملفات التوثيق تلقائية التوليد (من الكود عادة)، وغيرها. ينصح بإضافة ملف .gitignore في بداية إنشاء repository حتى نتجنب إضافة بعض الملفات عن طريق الخطأ وتلويث respository.
160
+
161
+ قواعد الأنماط التي يمكن وضعها ضمن ملف .gitignore هي كالتالي:
162
+
163
+ * الأسطر التي تبدأ بالرمز (#) يتم تجاهلها.
164
+ * أنماط glob القياسية تعمل.
165
+ * يمكن إنهاء النمط برمز (/) للدلالة على أنه يستهدف مجلداً.
166
+ * يمكن نفي نمط ما عن طريق وضع علامة التعجب (!) في بداية السطر قبل النمط.
167
+
168
+ أنماط Glob عبارة عن نسخة مبسطة من Regular Expressions يتم استخدامها ضمن واجهة الأوامر shell. رمز النجمة (`*`) يطابق صفر-محرفاً أو أكثر. `[abc]` تطابق أي محارف ضمن الأقواس المربعة في هذه الحالة تكون a b c؛ علامة الاستفهام (?) تطابق محرفاً واحداً فقط؛ بينما تطابق الأقواس المربعة التي تحوي على محارف مفصولة بإشارة hyphen أي محرفاً يقع في المجال بين محرف البداية والنهاية - مثلا [0-9] يطابق محارف الأرقام بين 0 و 9 ضمناً.
169
+
170
+ مثال عن ملف .gitignore:
171
+
172
+ # a comment – this is ignored
173
+ # no .a files
174
+ *.a
175
+ # but do track lib.a, even though you're ignoring .a files above
176
+ !lib.a
177
+ # only ignore the root TODO file, not subdir/TODO
178
+ /TODO
179
+ # ignore all files in the build/ directory
180
+ build/
181
+ # ignore doc/notes.txt, but not doc/server/arch.txt
182
+ doc/*.txt
183
+
184
+ ### مشاهدة التغيّرات المجهّزة والتغيّرات غير المجهّزة ###
185
+
186
+ إذا لم تكتف بالمعلومات التي يقدمها لك أمر `git status` يمكنك استخدام أمر `git diff` للحصول على معلومات تفصيلية حول التغيرات التي طرأت على الملفات. سنقوم لاحقاً بالتعمق في هذا الأمر، لكن الآن سنكتفي بالإشارة إلى الاستخدامات الغالبة له؛ حيث أنك ستستخدمه غالباً للحصول على أجوبة على هذين السؤالين: ما الذي قمنا بالتعديل عليه ولم نجهزه بعد لعملية commit؟ ما الملفات التي أصبحت جاهزة للدخول في عملية commit المقبلة؟
187
+ بالرغم من أنه يمكننا أن نحصل على هذه المعلومات باستخدام أمر `git status` إلا أنّ أمر `git diff` يوضح لنا التغيرات التي جرت على مستوى السطر والحرف - ما الذي قمنا بإضافته وما الذي أزلناه!
188
+
189
+ لنقل أنك قمت بالتعديل على ملف README مرة أخرى وأشرته للإضافة إلى عملية commit وقمت بالتعديل على ملف benchmarks.rb ولم تضفه إلى قائمة الملفات الجاهزة لعملية commit؛ إذا قمت بتنفيذ الأمر `status` ستشاهد مرة أخرى شيئاً من الشكل:
190
+
191
+ $ git status
192
+ # On branch master
193
+ # Changes to be committed:
194
+ # (use "git reset HEAD <file>..." to unstage)
195
+ #
196
+ # new file: README
197
+ #
198
+ # Changes not staged for commit:
199
+ # (use "git add <file>..." to update what will be committed)
200
+ #
201
+ # modified: benchmarks.rb
202
+ #
203
+
204
+ لترى ما قمت بالتعديل عليه ولم تجهزه للإضافة نفذ الأمر `git diff` بدون إضافات:
205
+
206
+ $ git diff
207
+ diff --git a/benchmarks.rb b/benchmarks.rb
208
+ index 3cb747f..da65585 100644
209
+ --- a/benchmarks.rb
210
+ +++ b/benchmarks.rb
211
+ @@ -36,6 +36,10 @@ def main
212
+ @commit.parents[0].parents[0].parents[0]
213
+ end
214
+
215
+ + run_code(x, 'commits 1') do
216
+ + git.commits.size
217
+ + end
218
+ +
219
+ run_code(x, 'commits 2') do
220
+ log = git.commits('master', 15)
221
+ log.size
222
+
223
+ يقوم هذا الأمر بعمل مقارنة بين الملفات ضمن مجلد العمل والملفات الموجودة في منطقة التعديلات المجهزة للإضافة staging area. وتخبرنا نتيجته بالتعديلات التي أجريناها ولم نقم بتجهيزها للإضافة إلى عملية commit المقبلة.
224
+
225
+ لمشاهدة الملفات ذات الحالة staged والتي ستدخل في عملية commit المقبلة، يمكن استخدام الأمر `git diff --cached` (بالنسبة للإصدارات 1.6.1 وما بعد من git يمكنك أيضاً استخدام الأمر `git diff --staged` )، كالتالي:
226
+
227
+ $ git diff --cached
228
+ diff --git a/README b/README
229
+ new file mode 100644
230
+ index 0000000..03902a1
231
+ --- /dev/null
232
+ +++ b/README2
233
+ @@ -0,0 +1,5 @@
234
+ +grit
235
+ + by Tom Preston-Werner, Chris Wanstrath
236
+ + http://github.com/mojombo/grit
237
+ +
238
+ +Grit is a Ruby library for extracting information from a Git repository
239
+
240
+ من الجدير بالذكر أن أمر `git diff` لوحده لا يقوم بعرض جميع التعديلات التي تمت من آخر commit - فهو يقوم بعرض فقط التعديلات التي لم تؤشر على أنها staged. ويمكن أن يسبب ذلك بعض الإرباك، حيث أنك إذا قمت بإضافة جميع التعديلات إلى قائمة staged فلن يقوم بعرض أي شي في خرج تنفيذه.
241
+
242
+ كمثال أيضاً، إذا قمنا بإضافة benchmarks.rb إلى قائمة staged ومن ثم قمنا بالتعديل عليه من جديد، يمكننا استخدام أمر `git diff` للحصول على لائحة بالتغييرات التي حصلت ولم تضف إلى قائمة staged كالتالي:
243
+
244
+ $ git add benchmarks.rb
245
+ $ echo '# test line' >> benchmarks.rb
246
+ $ git status
247
+ # On branch master
248
+ #
249
+ # Changes to be committed:
250
+ #
251
+ # modified: benchmarks.rb
252
+ #
253
+ # Changes not staged for commit:
254
+ #
255
+ # modified: benchmarks.rb
256
+ #
257
+
258
+
259
+ $ git diff
260
+ diff --git a/benchmarks.rb b/benchmarks.rb
261
+ index e445e28..86b2f7c 100644
262
+ --- a/benchmarks.rb
263
+ +++ b/benchmarks.rb
264
+ @@ -127,3 +127,4 @@ end
265
+ main()
266
+
267
+ ##pp Grit::GitRuby.cache_client.stats
268
+ +# test line
269
+
270
+ وباستخدام `git diff --cached` نتمكن من رؤية ما تم تجهيزه للإضافة إلى عملية commit القادمة:
271
+
272
+ $ git diff --cached
273
+ diff --git a/benchmarks.rb b/benchmarks.rb
274
+ index 3cb747f..e445e28 100644
275
+ --- a/benchmarks.rb
276
+ +++ b/benchmarks.rb
277
+ @@ -36,6 +36,10 @@ def main
278
+ @commit.parents[0].parents[0].parents[0]
279
+ end
280
+
281
+ + run_code(x, 'commits 1') do
282
+ + git.commits.size
283
+ + end
284
+ +
285
+ run_code(x, 'commits 2') do
286
+ log = git.commits('master', 15)
287
+ log.size
288
+
289
+ ### القيام بعملية (اعتماد) commit للتغيّرات ###
290
+
291
+ بعد اكمال تجهيز الملفات التي ترغب بإضافتها إلى النسخة snapshot الجديدة، يمكنك تنفيذ أمر commit ليتم اعتماد التعديلات التي أجريتها في سجل git. تذكر أنّ أي ملف لم يتم تجهيزه - سواء لم تقم بإضافته باستخدام الأمر git add بعد إنشاءه أو التعديل عليه - لن يدخل في هذه الإعتمادية، وستبقى على أنها ملفات تم تعديلها في مجلد العمل. أبسط طريقة لاعتماد التعديلات هي القيام بأمر `git commit` كالتالي:
292
+
293
+ $ git commit
294
+
295
+ تنفيذ هذا الأمر سيطلب منا إدخال رسالة عملية commit - عادة ما يتم فتح محرر النصوص المشار إليه بمتغير البيئة `$EDITOR`. يمكنك تهيئته عن طريق الأمر `git config --global core.editor` كما شاهدنا في الفصل الأول.
296
+
297
+ يقوم محرر النصوص بعرض هذه الشاشة (مثالنا باستخدام VIM):
298
+
299
+ # Please enter the commit message for your changes. Lines starting
300
+ # with '#' will be ignored, and an empty message aborts the commit.
301
+ # On branch master
302
+ # Changes to be committed:
303
+ # (use "git reset HEAD <file>..." to unstage)
304
+ #
305
+ # new file: README
306
+ # modified: benchmarks.rb
307
+ ~
308
+ ~
309
+ ~
310
+ ".git/COMMIT_EDITMSG" 10L, 283C
311
+
312
+ يمكنك ملاحظة أن رسالة عملية commit تحوي على خرج آخر عملية `git status` على شكل تعليقات بالإضافة إلى سطر فارغ في بداية الملف. يمكنك إزالة هذه التعليقات، أو يمكنك تركها لمساعدتك بتذكر ما قمت باعتماد تعديلاته. يمكنك الحصول على معلومات أكثر تفصلياً إذا قمت بتمرير الخيار `-v` إلى الأمر `git commit`. حيث يقوم ذلك بإضافة خرج أمر `git diff` إلى رسالة commit على شكل تعليقات أيضاً. عند إغلاق المحرر يقوم git بإنشاء commit ويتجاهل التعليقات.
313
+
314
+ علماً أنّه يمكنك كتابة رسالة الاعتمادية مباشرة من خلال تمرير الخيار `-m` إلى الأمر `git commit` على الشكل التالي:
315
+
316
+ $ git commit -m "Story 182: Fix benchmarks for speed"
317
+ [master]: created 463dc4f: "Fix benchmarks for speed"
318
+ 2 files changed, 3 insertions(+), 0 deletions(-)
319
+ create mode 100644 README
320
+
321
+ مبروك، لقد قمت بعمل أول commit لك! يعطيك خرج العملية معلومات عنها: في أي فرع branch تم الإعتماد (هنا master)، ما قيمة هاش SHA-1 الخاصة بالعملية ( هنا `463dc4f`)، عدد الملفات التي تغيّرت، بالإضافة إلى إحصاءات حول الأسطر التي أضيفت وأزيلت في هذه العملية.
322
+
323
+ تذكر أنّ عملية commit تأخذ صورة عن الملفات في قائمة staged. أي شيء لم تقم بإضافته إلى هذه القائمة ما زال في مجلد العمل بحالة "معدل" modified؛ يمكنك القيام بإضافتهم من خلال عملية commit جديدة إلى التأريخ في git. نستنتج أنّه في كل عملية commit يقوم git بأخذ "صورة" snapshot عن المشروع يمكننا العودة لها لاحقاً أو مقارنتها أو غير ذلك..
324
+
325
+ ### تجاوز منطقة التجهيز Staging Area ###
326
+
327
+ منطقة التجهيز تكون أحياناً معقدة أكثر مما تحتاج في عملك إلا أنّها مفيدة لعمل commits تماماً كما تودهم أن يكونوا. إذا أردت تجاوز منطقة التجهيز، يوفر git اختصاراً بسيطاً لذلك. باستخدام الأمر `git commit -a` يقوم git بإضافة الملفات المتتبعة إلى منطقة التجهيز بشكل تلقائي، كأنك قمت بعمل `git add`:
328
+
329
+ $ git status
330
+ # On branch master
331
+ #
332
+ # Changes not staged for commit:
333
+ #
334
+ # modified: benchmarks.rb
335
+ #
336
+ $ git commit -a -m 'added new benchmarks'
337
+ [master 83e38c7] added new benchmarks
338
+ 1 files changed, 5 insertions(+), 0 deletions(-)
339
+
340
+ لاحظ بأنك لاتحتاج إلى تنفيذ الأمر `git add` على ملف benchmark.rb قبل القيام بعملية commit.
341
+
342
+ ### إزالة الملفات ###
343
+
344
+ لحذف ملف من git، يجب عليك إزالته من قائمة الملفات المتتبعة (وبشكل أدق، إزالته من منطقة التجهيز) ومن ثم القيام بعملية commit. الأمر `git rm` يقوم بعمل ذلك كما يقوم بحذف الملف من مجلد العمل الخاص بك لذا لن تراه بعد الآن في قائمة الملفات غير المتتبعة في المرة المقبلة.
345
+
346
+ إذا قمت بإزالة الملف من مجلد العمل، يظهر تحت بند "تعديلات غير مجهزة للاعتماد" (أي _unstaged_) من خرج الأمر `git status`:
347
+
348
+ $ rm grit.gemspec
349
+ $ git status
350
+ # On branch master
351
+ #
352
+ # Changes not staged for commit:
353
+ # (use "git add/rm <file>..." to update what will be committed)
354
+ #
355
+ # deleted: grit.gemspec
356
+ #
357
+
358
+ فإذا قمت بتنفيذ أمر `git rm` يقوم بتجهيز عملية الحذف ليتم اعتمادها:
359
+
360
+ $ git rm grit.gemspec
361
+ rm 'grit.gemspec'
362
+ $ git status
363
+ # On branch master
364
+ #
365
+ # Changes to be committed:
366
+ # (use "git reset HEAD <file>..." to unstage)
367
+ #
368
+ # deleted: grit.gemspec
369
+ #
370
+
371
+ وفي المرة المقبلة التي ستقوم فيها بعمل commit، سيتم إزالة الملف من قائمة التتبع. إذا قمت مسبقاً بتعديل الملف وإضفته إلى الفهرس، يجب عليه تنفيذ عملية الحذف قسرياً وذلك بإضافة الخيار `-f`. يتم اتباع هذه الطريقة بغية حماية البيانات من أية عمليات حذف "عرضية" لملفات لم يتم تسجيلها ضمن git ولايمكن استعادتها بعد ذلك.
372
+
373
+ أما إذا أردت إزالة الملف من منطقة التجهيز مع الحفاظ عليه في مجلد العمل (أي إزالته من تتبع git مع بقاءه على وسيطة التخزين) - وهو شيء مفيد إذا قمت بنسيان إضافة شيء ما إلى ملف `.gitignore` وأضفته عن طريق الخطأ ؛ كملف log كبير مثلاً - استخدم الخيار `--cached` مع الأمر `git rm` كالتالي:
374
+
375
+ $ git rm --cached readme.txt
376
+
377
+ يمكنك تمرير أسماء ملفات، مجلدات، وأنماط glob للأمر `git rm`. وهذا يعني بأنه يمكننا عمل أشياء كالتالي:
378
+
379
+ $ git rm log/\*.log
380
+
381
+ لاحظ الشرطة العكسية (`\`) قبل رمز النجمة `*`. إنّها ضرورية لأن git يقوم بعمل توسعة الأسماء الخاصة به بالإضافة إلى التوسعة الخاصة بسطر الأوامر. هذا الأمر يقوم بحذف كافة الملفات التي تملك اللاحقة `.log` في مجلد `/log`. أو يمكنك عمل شيء كالتالي:
382
+
383
+ $ git rm \*~
384
+
385
+ وهذا الأمر يقوم بحذف كافة الملفات المنتهية بالمحرف `~`.
386
+
387
+ ### نقل الملفات ###
388
+
389
+ على خلاف أغلب أنظمة إدارة الإصدارات VCS الأخرى، لا يقوم git بتعقب حركة الملفات بشكل صريح. إذا قمت بإعادة تسمية ملف ضمن git، لايتم تسجيل أي بيانات وصفية metadata في git تقوم بأنك قمت بإعادة تسمية الملف. لكن، git ذكي جداً في استعياب ذلك - وسنقوم بمناقشة الأمر بعد قليل.
390
+
391
+ إذا أردت القيام بإعادة تسمية ملف يمكنك استخدام أمر `mv` في git كالتالي:
392
+
393
+ $ git mv file_from file_to
394
+
395
+ إذا قمنا بتنفيذ الأمر والنظر إلى خرج أمر `git status`:
396
+
397
+ $ git mv README.txt README
398
+ $ git status
399
+ # On branch master
400
+ # Your branch is ahead of 'origin/master' by 1 commit.
401
+ #
402
+ # Changes to be committed:
403
+ # (use "git reset HEAD <file>..." to unstage)
404
+ #
405
+ # renamed: README.txt -> README
406
+ #
407
+
408
+ وهو مكافئ للقيام بتنفيذ الأوامر التالي على التسلسل:
409
+
410
+ $ mv README.txt README
411
+ $ git rm README.txt
412
+ $ git add README
413
+
414
+ يدرك git بأنك قمت بعملية إعادة تسمية، لذا فالإختلاف الوحيد بين الطريقتين هو أنّ `git mv` عبارة عن أمر واحد، وليس ثلاثة أوامر. يمكن الاستفادة من هذه الخاصة باستخدام أية أدوات للقيام بعمليات إعادة التسمية، واستخدام add/rm قبل القيام بعملية commit.
415
+
416
+ ## مراجعة تأريخ عمليات commit ##
417
+
418
+ بعد قيامك بعدد من عمليات الاعتماد commit، أو استنساخ repository بسجل تأريخ، ربما ستود إلقاء نظرة على ما جرى. أبسط وأقوى أداة لعمل ذلك هي الأمر `git log`.
419
+
420
+ هذه الأمثلة تستخدم مشروع بسيط جداً يدعى simplegit أقوم باستخدامه في عمليات العرض بأغلب الأحيان. للحصول على المشروع قم باستنساخه عن موقع github كالتالي:
421
+
422
+ git clone git://github.com/schacon/simplegit-progit.git
423
+
424
+ عندما تقوم بعمل `git log` ضمن المشروع، سيظهر لديك خرج مشابه للتالي:
425
+
426
+ $ git log
427
+ commit ca82a6dff817ec66f44342007202690a93763949
428
+ Author: Scott Chacon <schacon@gee-mail.com>
429
+ Date: Mon Mar 17 21:52:11 2008 -0700
430
+
431
+ changed the version number
432
+
433
+ commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
434
+ Author: Scott Chacon <schacon@gee-mail.com>
435
+ Date: Sat Mar 15 16:40:33 2008 -0700
436
+
437
+ removed unnecessary test code
438
+
439
+ commit a11bef06a3f659402fe7563abf99ad00de2209e6
440
+ Author: Scott Chacon <schacon@gee-mail.com>
441
+ Date: Sat Mar 15 10:31:28 2008 -0700
442
+
443
+ first commit
444
+
445
+ بتنفيذ الأمر بدون بارمترات، يقوم git بعرض عمليات commit في repository بترتيب زمني معكوس - من الأحدث إلى الأقدم. كما يقوم بعرض بجانب كل commit هاش SHA-1 checksum الخاص بها، اسم وبريد الكاتب الإلكتروني، تاريخ الاعتماد، ورسالة الاعتماد.
446
+
447
+ يمكن إرفاق الأمر `git log` بعدد كبير من الخيارات للحصول على المعلومات التي نريدها بالضبط.. تجد في الأسفل مثالاً عن أكثر الخيارات استخداماً.
448
+
449
+ أحد أهم الخيارات هو `-p`، والذي يقوم بإظهار الفوارق المستحدثة بين عمليات commit المختلفة. يمكن أيضاً استخدام الخيار `-2` ليحد خرج النتيجة إلى آخر عمليتين:
450
+
451
+ $ git log –p -2
452
+ commit ca82a6dff817ec66f44342007202690a93763949
453
+ Author: Scott Chacon <schacon@gee-mail.com>
454
+ Date: Mon Mar 17 21:52:11 2008 -0700
455
+
456
+ changed the version number
457
+
458
+ diff --git a/Rakefile b/Rakefile
459
+ index a874b73..8f94139 100644
460
+ --- a/Rakefile
461
+ +++ b/Rakefile
462
+ @@ -5,7 +5,7 @@ require 'rake/gempackagetask'
463
+ spec = Gem::Specification.new do |s|
464
+ - s.version = "0.1.0"
465
+ + s.version = "0.1.1"
466
+ s.author = "Scott Chacon"
467
+
468
+ commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
469
+ Author: Scott Chacon <schacon@gee-mail.com>
470
+ Date: Sat Mar 15 16:40:33 2008 -0700
471
+
472
+ removed unnecessary test code
473
+
474
+ diff --git a/lib/simplegit.rb b/lib/simplegit.rb
475
+ index a0a60ae..47c6340 100644
476
+ --- a/lib/simplegit.rb
477
+ +++ b/lib/simplegit.rb
478
+ @@ -18,8 +18,3 @@ class SimpleGit
479
+ end
480
+
481
+ end
482
+ -
483
+ -if $0 == __FILE__
484
+ - git = SimpleGit.new
485
+ - puts git.show
486
+ -end
487
+
488
+
489
+ هذا الخيار يعرض نفس المعلومات بالإضافة خرج diff بعده مباشرة. فهو مهم جداً من أجل مراجعة الكود واستعراض ما الذي تغير بشكل سريع ضمن سلسلة من عمليات commit. يمكنك أيضاً استخدام خيارات للتلخيص مع أمر `git log`. على سبيل المثال، إذا أردت رؤية بعض الإحصاءات المختصرة لكل commit، يمكنك استخدام الخيار `stat`:
490
+
491
+ $ git log --stat
492
+ commit ca82a6dff817ec66f44342007202690a93763949
493
+ Author: Scott Chacon <schacon@gee-mail.com>
494
+ Date: Mon Mar 17 21:52:11 2008 -0700
495
+
496
+ changed the version number
497
+
498
+ Rakefile | 2 +-
499
+ 1 files changed, 1 insertions(+), 1 deletions(-)
500
+
501
+ commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
502
+ Author: Scott Chacon <schacon@gee-mail.com>
503
+ Date: Sat Mar 15 16:40:33 2008 -0700
504
+
505
+ removed unnecessary test code
506
+
507
+ lib/simplegit.rb | 5 -----
508
+ 1 files changed, 0 insertions(+), 5 deletions(-)
509
+
510
+ commit a11bef06a3f659402fe7563abf99ad00de2209e6
511
+ Author: Scott Chacon <schacon@gee-mail.com>
512
+ Date: Sat Mar 15 10:31:28 2008 -0700
513
+
514
+ first commit
515
+
516
+ README | 6 ++++++
517
+ Rakefile | 23 +++++++++++++++++++++++
518
+ lib/simplegit.rb | 25 +++++++++++++++++++++++++
519
+ 3 files changed, 54 insertions(+), 0 deletions(-)
520
+
521
+ كما ترى باستخدام الخيار `--stat` يتم عرض قائمة من الملفات المعدلة، عدد الملفات التي تغيرت، وعدد الأسطر التي أضيفت أو أزيلت. كما يضع ملخصاً للمعلومات في النهاية.
522
+ يوجد خيار مفيد آخر وهو `--pretty`. هذا الخيار يغير خرج السل إلى صيغ غير الافتراضية. يوجد بعضها مركب مسبقاً. مثلاً `oneline` يقوم بطباعة كل commit على سطر لوحدها، وهذا أمر مفيد في حال كنت تنظر إلى العديد من عمليات commit. بالإضافة إلى `short`، `full` و `fuller` والتي تعرض خرجاً تقريباً بنفس الصيغة مع معلومات أكثر أو أقل:
523
+
524
+ $ git log --pretty=oneline
525
+ ca82a6dff817ec66f44342007202690a93763949 changed the version number
526
+ 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test code
527
+ a11bef06a3f659402fe7563abf99ad00de2209e6 first commit
528
+
529
+ أكثر الخيارات أهمية هو `format`، والذي يسمح لك بتحديد صيغة الخرج بشكل صريح بما يتناسب مع إعرابها آلياً - حيث أنك تعرف أنّه لن يتغير عند التحديث إلى git:
530
+
531
+ $ git log --pretty=format:"%h - %an, %ar : %s"
532
+ ca82a6d - Scott Chacon, 11 months ago : changed the version number
533
+ 085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code
534
+ a11bef0 - Scott Chacon, 11 months ago : first commit
535
+
536
+ الجدول 2-1 يعرض بعض الخيارات المفيدة التي يمكن إضافتها إلى الصيغة.
537
+
538
+ الخيار وصف الخرج
539
+ %H Commit هاش
540
+ %h الهاش الاعتمادي المختصر
541
+ %T هاش الشجرة
542
+ %t هاش الشجرة المختصر
543
+ %P هاشات الوالد
544
+ %p هاشات الوالد المختصرة
545
+ %an اسم الكاتب
546
+ %ae بريد الكاتب الإلكتروني
547
+ %ad تاريخ الكاتب (يراعي الصيغة –date= option)
548
+ %ar تاريخ الكاتب - نسبياً
549
+ %cn اسم منفذ الاعتماد
550
+ %ce بريد منفذ الاعتماد الإلكتروني
551
+ %cd تاريخ منفذ الاعتماد
552
+ %cr تاريخ منفذ الاعتماد - نسبياً
553
+ %s العنوان
554
+
555
+ قد تتسائل عن الاختلاف بين _الكاتب_ AUTHOR و _منفذ الاعتماد_ COMMITTER. الكاتب هو الشخص الذي كتب العمل بداية، بينما منفذ الاعتماد هو آخر شخص طبق العمل. لذا، إذا أرسلت باتشاً إلى مشروع وأحد المطورين الرئيسين قام بتطبيق الباتش، تأخذان كلاكما الاعتمادية - أنت ككاتب وهو كمنفذ اعتماد.
556
+
557
+ وتكون هذه الخيارات مفيدة أكثر بالترافق مع الخيار `--graph`. حيث يضيف هذا الأمر غراف ASCII بسيط يوضح تأريخ الأفرع و الدمج، لاحظ التالي:
558
+
559
+ $ git log --pretty=format:"%h %s" --graph
560
+ * 2d3acf9 ignore errors from SIGCHLD on trap
561
+ * 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
562
+ |\
563
+ | * 420eac9 Added a method for getting the current branch.
564
+ * | 30e367c timeout code and tests
565
+ * | 5a09431 add timeout protection to grit
566
+ * | e1193f8 support for heads with slashes in them
567
+ |/
568
+ * d6016bc require time for xmlschema
569
+ * 11d191e Merge branch 'defunkt' into local
570
+
571
+ يوجد مجموعة من الخيارات البسيطة مع أمر `git log`. يوضح الجدول 2-2 قائمة من الخيارات التي قمنا بتغطيتها حتى الآن وبعض صيغ التنسيق الشائعة والتي قد تكون مفيدة، وبجانبها شرح مبسط عن التغيير الذي تجريه على الخرج.
572
+
573
+ الخيار الوصف
574
+ -p يظهر الباتش المدخل مع كل عملية commit.
575
+ --stat يظهر إحصاءات حول التعديلات التي حصلت على الملفات مع كل عملية commit.
576
+ --shortstat Display only the changed/insertions/deletions line from the --stat command.
577
+ --name-only يظهر قائمة الملفات المعدلة.
578
+ --name-status يظهر قائمة الملفات المعدلة عن طريق الإضافة والحذف وغير ذلك.
579
+ --abbrev-commit يظهر أول مجموعة من هاش SHA-1 بدلاً عن كامل الأحرف 40.
580
+ --relative-date Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.
581
+ --graph عرض غراف ASCII مع الخرج يظهر عمليات التفريع و الدمج.
582
+ --pretty Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).
583
+
584
+ ### تحديد خرج السجل ###
585
+
586
+ بالإضافة تحديد شكل الخرج، يسمح git بأخذ مجموعة جزئية فقط من الخرج. وقد قمت بمشاهدة ذلك مسبقاً - الخيار `-2` المستخدم لعرض آخر عمليتي commit. في الواقع يمكنك استخدام `-<n>` حيث `n` هي عدد صحيح لعرض آخر `n` عملية commit. في الحقيقة، لن تستخدمها على الغالب، لأن git يقوم بتمرير كامل الخرج لبرنامج تصفح لتتمكن من تصفح عمليات commit صفحة صفحة.
587
+
588
+ من الخيارات الهامة جداً، المحددات الزمنية مثل `--since` و `--until`. على سبيل المثال، هذا الأمر يعطيك قائمة بعمليات commit التي حصلت في آخر أسبوعين:
589
+
590
+ $ git log --since=2.weeks
591
+
592
+ ويعمل هذا الأمر مع أنواع كثيرة من الصيغ - يمكنك تحديد تاريخ محدد ("2008-01-15") أو تاريخ نسبي مثل "2 years 1 day 3 minutes ago".
593
+
594
+ يكطمط أيضاً تصفية قائمة عمليات commit من خلال محددات البحث. مثلاً خيار `--author` يقوم بتصفية النتائج وفق كاتب محدد، و `--grep` يقوم بالفلترة عن طريق كلمة مفتاحية. (لاحظ أنّه إذا قمت بإضافة خياراي author و grep، يجب عليك إضافة الخيار `--all-match` أو سيقوم git بعمل مطابقة مع أحدهما فقط).
595
+
596
+ آخر الخيارات الهامة التي يمكن تمريرها إلى الأمر `git log` كمصناف هي المسار. إذا قمت بتحديد مجلد أو اسم ملف، يمكنك تحديد الخرج إلى عمليات commit التي آثرت في هذا المسار. ودائماً ما يكون آخر خيار يوضع في `log` ويسبق بداشين double dashes (`--`) ليفصل المسارات عن الخيارات.
597
+
598
+ في الجدول 2-3 - نعرض الخيارات التي يمكن إضافتها مع log.
599
+
600
+ خيار وصف
601
+ -(n) يظهر آن n عملية commit.
602
+ --since, --after تحديد عمليات commit بعد التاريخ الذي يتلوها.
603
+ --until, --before تحديد عمليات commit حتى التاريخ الذي يتلوها.
604
+ --author فقط أظهر عمليات commit التابعة لهذا الكاتب.
605
+ --committer فقط أظهر عمليات commit التابعة لهذا المعتمد.
606
+
607
+ على سبيل المثال، إذا أردت رؤية أي عمليات commit عدلت ملفات الاختبار في تأريخ الكود المصدري والتي قام Junio Hamano بعملها ولم يتم دمجها في شهر أوكتوبر 2008، يمكن كتابة هذا الأمر:
608
+
609
+ $ git log --pretty="%h - %s" --author=gitster --since="2008-10-01" \
610
+ --before="2008-11-01" --no-merges -- t/
611
+ 5610e3b - Fix testcase failure when extended attribute
612
+ acd3b9e - Enhance hold_lock_file_for_{update,append}()
613
+ f563754 - demonstrate breakage of detached checkout wi
614
+ d1a43f2 - reset --hard/read-tree --reset -u: remove un
615
+ 51a94af - Fix "checkout --track -b newbranch" on detac
616
+ b0ad11e - pull: allow "git pull origin $something:$cur
617
+
618
+ من بين 20 ألف عملية commit تقريباً في تأريخ git الخاص بهذا الكود المصدري، أظهر الأمر فقط عمليات الاعتماد الستة المطابقة لمحددات البحث.
619
+
620
+ ### Using a GUI to Visualize History ###
621
+
622
+ If you like to use a more graphical tool to visualize your commit history, you may want to take a look at a Tcl/Tk program called gitk that is distributed with Git. Gitk is basically a visual `git log` tool, and it accepts nearly all the filtering options that `git log` does. If you type gitk on the command line in your project, you should see something like Figure 2-2.
623
+
624
+ Insert 18333fig0202.png
625
+ Figure 2-2. The gitk history visualizer.
626
+
627
+ You can see the commit history in the top half of the window along with a nice ancestry graph. The diff viewer in the bottom half of the window shows you the changes introduced at any commit you click.
628
+
629
+ ## Undoing Things ##
630
+
631
+ At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong.
632
+
633
+ ### Changing Your Last Commit ###
634
+
635
+ One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the `--amend` option:
636
+
637
+ $ git commit --amend
638
+
639
+ This command takes your staging area and uses it for the commit. If you’ve have made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same and all you’ll change is your commit message.
640
+
641
+ The same commit-message editor fires up, but it already contains the message of your previous commit. You can edit the message the same as always, but it overwrites your previous commit.
642
+
643
+ As an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit, you can do something like this:
644
+
645
+ $ git commit -m 'initial commit'
646
+ $ git add forgotten_file
647
+ $ git commit --amend
648
+
649
+ All three of these commands end up with a single commit — the second commit replaces the results of the first.
650
+
651
+ ### Unstaging a Staged File ###
652
+
653
+ The next two sections demonstrate how to wrangle your staging area and working directory changes. The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. For example, let’s say you’ve changed two files and want to commit them as two separate changes, but you accidentally type `git add *` and stage them both. How can you unstage one of the two? The `git status` command reminds you:
654
+
655
+ $ git add .
656
+ $ git status
657
+ # On branch master
658
+ # Changes to be committed:
659
+ # (use "git reset HEAD <file>..." to unstage)
660
+ #
661
+ # modified: README.txt
662
+ # modified: benchmarks.rb
663
+ #
664
+
665
+ Right below the “Changes to be committed” text, it says use `git reset HEAD <file>...` to unstage. So, let’s use that advice to unstage the benchmarks.rb file:
666
+
667
+ $ git reset HEAD benchmarks.rb
668
+ benchmarks.rb: locally modified
669
+ $ git status
670
+ # On branch master
671
+ # Changes to be committed:
672
+ # (use "git reset HEAD <file>..." to unstage)
673
+ #
674
+ # modified: README.txt
675
+ #
676
+ # Changes not staged for commit:
677
+ # (use "git add <file>..." to update what will be committed)
678
+ # (use "git checkout -- <file>..." to discard changes in working directory)
679
+ #
680
+ # modified: benchmarks.rb
681
+ #
682
+
683
+ The command is a bit strange, but it works. The benchmarks.rb file is modified but once again unstaged.
684
+
685
+ ### Unmodifying a Modified File ###
686
+
687
+ What if you realize that you don’t want to keep your changes to the benchmarks.rb file? How can you easily unmodify it — revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? Luckily, `git status` tells you how to do that, too. In the last example output, the unstaged area looks like this:
688
+
689
+ # Changes not staged for commit:
690
+ # (use "git add <file>..." to update what will be committed)
691
+ # (use "git checkout -- <file>..." to discard changes in working directory)
692
+ #
693
+ # modified: benchmarks.rb
694
+ #
695
+
696
+ It tells you pretty explicitly how to discard the changes you’ve made (at least, the newer versions of Git, 1.6.1 and later, do this — if you have an older version, we highly recommend upgrading it to get some of these nicer usability features). Let’s do what it says:
697
+
698
+ $ git checkout -- benchmarks.rb
699
+ $ git status
700
+ # On branch master
701
+ # Changes to be committed:
702
+ # (use "git reset HEAD <file>..." to unstage)
703
+ #
704
+ # modified: README.txt
705
+ #
706
+
707
+ You can see that the changes have been reverted. You should also realize that this is a dangerous command: any changes you made to that file are gone — you just copied another file over it. Don’t ever use this command unless you absolutely know that you don’t want the file. If you just need to get it out of the way, we’ll go over stashing and branching in the next chapter; these are generally better ways to go.
708
+
709
+ Remember, anything that is committed in Git can almost always be recovered. Even commits that were on branches that were deleted or commits that were overwritten with an `--amend` commit can be recovered (see Chapter 9 for data recovery). However, anything you lose that was never committed is likely never to be seen again.
710
+
711
+ ## Working with Remotes ##
712
+
713
+ To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. You can have several of them, each of which generally is either read-only or read/write for you. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.
714
+ Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. In this section, we’ll cover these remote-management skills.
715
+
716
+ ### Showing Your Remotes ###
717
+
718
+ To see which remote servers you have configured, you can run the git remote command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin — that is the default name Git gives to the server you cloned from:
719
+
720
+ $ git clone git://github.com/schacon/ticgit.git
721
+ Initialized empty Git repository in /private/tmp/ticgit/.git/
722
+ remote: Counting objects: 595, done.
723
+ remote: Compressing objects: 100% (269/269), done.
724
+ remote: Total 595 (delta 255), reused 589 (delta 253)
725
+ Receiving objects: 100% (595/595), 73.31 KiB | 1 KiB/s, done.
726
+ Resolving deltas: 100% (255/255), done.
727
+ $ cd ticgit
728
+ $ git remote
729
+ origin
730
+
731
+ You can also specify `-v`, which shows you the URL that Git has stored for the shortname to be expanded to:
732
+
733
+ $ git remote -v
734
+ origin git://github.com/schacon/ticgit.git
735
+
736
+ If you have more than one remote, the command lists them all. For example, my Grit repository looks something like this.
737
+
738
+ $ cd grit
739
+ $ git remote -v
740
+ bakkdoor git://github.com/bakkdoor/grit.git
741
+ cho45 git://github.com/cho45/grit.git
742
+ defunkt git://github.com/defunkt/grit.git
743
+ koke git://github.com/koke/grit.git
744
+ origin git@github.com:mojombo/grit.git
745
+
746
+ This means we can pull contributions from any of these users pretty easily. But notice that only the origin remote is an SSH URL, so it’s the only one I can push to (we’ll cover why this is in Chapter 4).
747
+
748
+ ### Adding Remote Repositories ###
749
+
750
+ I’ve mentioned and given some demonstrations of adding remote repositories in previous sections, but here is how to do it explicitly. To add a new remote Git repository as a shortname you can reference easily, run `git remote add [shortname] [url]`:
751
+
752
+ $ git remote
753
+ origin
754
+ $ git remote add pb git://github.com/paulboone/ticgit.git
755
+ $ git remote -v
756
+ origin git://github.com/schacon/ticgit.git
757
+ pb git://github.com/paulboone/ticgit.git
758
+
759
+ Now you can use the string pb on the command line in lieu of the whole URL. For example, if you want to fetch all the information that Paul has but that you don’t yet have in your repository, you can run git fetch pb:
760
+
761
+ $ git fetch pb
762
+ remote: Counting objects: 58, done.
763
+ remote: Compressing objects: 100% (41/41), done.
764
+ remote: Total 44 (delta 24), reused 1 (delta 0)
765
+ Unpacking objects: 100% (44/44), done.
766
+ From git://github.com/paulboone/ticgit
767
+ * [new branch] master -> pb/master
768
+ * [new branch] ticgit -> pb/ticgit
769
+
770
+ Paul’s master branch is accessible locally as `pb/master` — you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
771
+
772
+ ### Fetching and Pulling from Your Remotes ###
773
+
774
+ As you just saw, to get data from your remote projects, you can run:
775
+
776
+ $ git fetch [remote-name]
777
+
778
+ The command goes out to that remote project and pulls down all the data from that remote project that you don’t have yet. After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time. (We’ll go over what branches are and how to use them in much more detail in Chapter 3.)
779
+
780
+ If you clone a repository, the command automatically adds that remote repository under the name origin. So, `git fetch origin` fetches any new work that has been pushed to that server since you cloned (or last fetched from) it. It’s important to note that the fetch command pulls the data to your local repository — it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
781
+
782
+ If you have a branch set up to track a remote branch (see the next section and Chapter 3 for more information), you can use the `git pull` command to automatically fetch and then merge a remote branch into your current branch. This may be an easier or more comfortable workflow for you; and by default, the `git clone` command automatically sets up your local master branch to track the remote master branch on the server you cloned from (assuming the remote has a master branch). Running `git pull` generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.
783
+
784
+ ### Pushing to Your Remotes ###
785
+
786
+ When you have your project at a point that you want to share, you have to push it upstream. The command for this is simple: `git push [remote-name] [branch-name]`. If you want to push your master branch to your `origin` server (again, cloning generally sets up both of those names for you automatically), then you can run this to push your work back up to the server:
787
+
788
+ $ git push origin master
789
+
790
+ This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime. If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected. You’ll have to pull down their work first and incorporate it into yours before you’ll be allowed to push. See Chapter 3 for more detailed information on how to push to remote servers.
791
+
792
+ ### Inspecting a Remote ###
793
+
794
+ If you want to see more information about a particular remote, you can use the `git remote show [remote-name]` command. If you run this command with a particular shortname, such as `origin`, you get something like this:
795
+
796
+ $ git remote show origin
797
+ * remote origin
798
+ URL: git://github.com/schacon/ticgit.git
799
+ Remote branch merged with 'git pull' while on branch master
800
+ master
801
+ Tracked remote branches
802
+ master
803
+ ticgit
804
+
805
+ It lists the URL for the remote repository as well as the tracking branch information. The command helpfully tells you that if you’re on the master branch and you run `git pull`, it will automatically merge in the master branch on the remote after it fetches all the remote references. It also lists all the remote references it has pulled down.
806
+
807
+ That is a simple example you’re likely to encounter. When you’re using Git more heavily, however, you may see much more information from `git remote show`:
808
+
809
+ $ git remote show origin
810
+ * remote origin
811
+ URL: git@github.com:defunkt/github.git
812
+ Remote branch merged with 'git pull' while on branch issues
813
+ issues
814
+ Remote branch merged with 'git pull' while on branch master
815
+ master
816
+ New remote branches (next fetch will store in remotes/origin)
817
+ caching
818
+ Stale tracking branches (use 'git remote prune')
819
+ libwalker
820
+ walker2
821
+ Tracked remote branches
822
+ acl
823
+ apiv2
824
+ dashboard2
825
+ issues
826
+ master
827
+ postgres
828
+ Local branch pushed with 'git push'
829
+ master:master
830
+
831
+ This command shows which branch is automatically pushed when you run `git push` on certain branches. It also shows you which remote branches on the server you don’t yet have, which remote branches you have that have been removed from the server, and multiple branches that are automatically merged when you run `git pull`.
832
+
833
+ ### Removing and Renaming Remotes ###
834
+
835
+ If you want to rename a reference, in newer versions of Git you can run `git remote rename` to change a remote’s shortname. For instance, if you want to rename `pb` to `paul`, you can do so with `git remote rename`:
836
+
837
+ $ git remote rename pb paul
838
+ $ git remote
839
+ origin
840
+ paul
841
+
842
+ It’s worth mentioning that this changes your remote branch names, too. What used to be referenced at `pb/master` is now at `paul/master`.
843
+
844
+ If you want to remove a reference for some reason — you’ve moved the server or are no longer using a particular mirror, or perhaps a contributor isn’t contributing anymore — you can use `git remote rm`:
845
+
846
+ $ git remote rm paul
847
+ $ git remote
848
+ origin
849
+
850
+ ## Tagging ##
851
+
852
+ Like most VCSs, Git has the ability to tag specific points in history as being important. Generally, people use this functionality to mark release points (v1.0, and so on). In this section, you’ll learn how to list the available tags, how to create new tags, and what the different types of tags are.
853
+
854
+ ### Listing Your Tags ###
855
+
856
+ Listing the available tags in Git is straightforward. Just type `git tag`:
857
+
858
+ $ git tag
859
+ v0.1
860
+ v1.3
861
+
862
+ This command lists the tags in alphabetical order; the order in which they appear has no real importance.
863
+
864
+ You can also search for tags with a particular pattern. The Git source repo, for instance, contains more than 240 tags. If you’re only interested in looking at the 1.4.2 series, you can run this:
865
+
866
+ $ git tag -l 'v1.4.2.*'
867
+ v1.4.2.1
868
+ v1.4.2.2
869
+ v1.4.2.3
870
+ v1.4.2.4
871
+
872
+ ### Creating Tags ###
873
+
874
+ Git uses two main types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.
875
+
876
+ ### Annotated Tags ###
877
+
878
+ Creating an annotated tag in Git is simple. The easiest way is to specify `-a` when you run the `tag` command:
879
+
880
+ $ git tag -a v1.4 -m 'my version 1.4'
881
+ $ git tag
882
+ v0.1
883
+ v1.3
884
+ v1.4
885
+
886
+ The `-m` specifies a tagging message, which is stored with the tag. If you don’t specify a message for an annotated tag, Git launches your editor so you can type it in.
887
+
888
+ You can see the tag data along with the commit that was tagged by using the `git show` command:
889
+
890
+ $ git show v1.4
891
+ tag v1.4
892
+ Tagger: Scott Chacon <schacon@gee-mail.com>
893
+ Date: Mon Feb 9 14:45:11 2009 -0800
894
+
895
+ my version 1.4
896
+ commit 15027957951b64cf874c3557a0f3547bd83b3ff6
897
+ Merge: 4a447f7... a6b4c97...
898
+ Author: Scott Chacon <schacon@gee-mail.com>
899
+ Date: Sun Feb 8 19:02:46 2009 -0800
900
+
901
+ Merge branch 'experiment'
902
+
903
+ That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information.
904
+
905
+ ### Signed Tags ###
906
+
907
+ You can also sign your tags with GPG, assuming you have a private key. All you have to do is use `-s` instead of `-a`:
908
+
909
+ $ git tag -s v1.5 -m 'my signed 1.5 tag'
910
+ You need a passphrase to unlock the secret key for
911
+ user: "Scott Chacon <schacon@gee-mail.com>"
912
+ 1024-bit DSA key, ID F721C45A, created 2009-02-09
913
+
914
+ If you run `git show` on that tag, you can see your GPG signature attached to it:
915
+
916
+ $ git show v1.5
917
+ tag v1.5
918
+ Tagger: Scott Chacon <schacon@gee-mail.com>
919
+ Date: Mon Feb 9 15:22:20 2009 -0800
920
+
921
+ my signed 1.5 tag
922
+ -----BEGIN PGP SIGNATURE-----
923
+ Version: GnuPG v1.4.8 (Darwin)
924
+
925
+ iEYEABECAAYFAkmQurIACgkQON3DxfchxFr5cACeIMN+ZxLKggJQf0QYiQBwgySN
926
+ Ki0An2JeAVUCAiJ7Ox6ZEtK+NvZAj82/
927
+ =WryJ
928
+ -----END PGP SIGNATURE-----
929
+ commit 15027957951b64cf874c3557a0f3547bd83b3ff6
930
+ Merge: 4a447f7... a6b4c97...
931
+ Author: Scott Chacon <schacon@gee-mail.com>
932
+ Date: Sun Feb 8 19:02:46 2009 -0800
933
+
934
+ Merge branch 'experiment'
935
+
936
+ A bit later, you’ll learn how to verify signed tags.
937
+
938
+ ### Lightweight Tags ###
939
+
940
+ Another way to tag commits is with a lightweight tag. This is basically the commit checksum stored in a file — no other information is kept. To create a lightweight tag, don’t supply the `-a`, `-s`, or `-m` option:
941
+
942
+ $ git tag v1.4-lw
943
+ $ git tag
944
+ v0.1
945
+ v1.3
946
+ v1.4
947
+ v1.4-lw
948
+ v1.5
949
+
950
+ This time, if you run `git show` on the tag, you don’t see the extra tag information. The command just shows the commit:
951
+
952
+ $ git show v1.4-lw
953
+ commit 15027957951b64cf874c3557a0f3547bd83b3ff6
954
+ Merge: 4a447f7... a6b4c97...
955
+ Author: Scott Chacon <schacon@gee-mail.com>
956
+ Date: Sun Feb 8 19:02:46 2009 -0800
957
+
958
+ Merge branch 'experiment'
959
+
960
+ ### Verifying Tags ###
961
+
962
+ To verify a signed tag, you use `git tag -v [tag-name]`. This command uses GPG to verify the signature. You need the signer’s public key in your keyring for this to work properly:
963
+
964
+ $ git tag -v v1.4.2.1
965
+ object 883653babd8ee7ea23e6a5c392bb739348b1eb61
966
+ type commit
967
+ tag v1.4.2.1
968
+ tagger Junio C Hamano <junkio@cox.net> 1158138501 -0700
969
+
970
+ GIT 1.4.2.1
971
+
972
+ Minor fixes since 1.4.2, including git-mv and git-http with alternates.
973
+ gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
974
+ gpg: Good signature from "Junio C Hamano <junkio@cox.net>"
975
+ gpg: aka "[jpeg image of size 1513]"
976
+ Primary key fingerprint: 3565 2A26 2040 E066 C9A7 4A7D C0C6 D9A4 F311 9B9A
977
+
978
+ If you don’t have the signer’s public key, you get something like this instead:
979
+
980
+ gpg: Signature made Wed Sep 13 02:08:25 2006 PDT using DSA key ID F3119B9A
981
+ gpg: Can't check signature: public key not found
982
+ error: could not verify the tag 'v1.4.2.1'
983
+
984
+ ### Tagging Later ###
985
+
986
+ You can also tag commits after you’ve moved past them. Suppose your commit history looks like this:
987
+
988
+ $ git log --pretty=oneline
989
+ 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
990
+ a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
991
+ 0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
992
+ 6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'
993
+ 0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function
994
+ 4682c3261057305bdd616e23b64b0857d832627b added a todo file
995
+ 166ae0c4d3f420721acbb115cc33848dfcc2121a started write support
996
+ 9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile
997
+ 964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo
998
+ 8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme
999
+
1000
+ Now, suppose you forgot to tag the project at v1.2, which was at the "updated rakefile" commit. You can add it after the fact. To tag that commit, you specify the commit checksum (or part of it) at the end of the command:
1001
+
1002
+ $ git tag -a v1.2 9fceb02
1003
+
1004
+ You can see that you’ve tagged the commit:
1005
+
1006
+ $ git tag
1007
+ v0.1
1008
+ v1.2
1009
+ v1.3
1010
+ v1.4
1011
+ v1.4-lw
1012
+ v1.5
1013
+
1014
+ $ git show v1.2
1015
+ tag v1.2
1016
+ Tagger: Scott Chacon <schacon@gee-mail.com>
1017
+ Date: Mon Feb 9 15:32:16 2009 -0800
1018
+
1019
+ version 1.2
1020
+ commit 9fceb02d0ae598e95dc970b74767f19372d61af8
1021
+ Author: Magnus Chacon <mchacon@gee-mail.com>
1022
+ Date: Sun Apr 27 20:43:35 2008 -0700
1023
+
1024
+ updated rakefile
1025
+ ...
1026
+
1027
+ ### Sharing Tags ###
1028
+
1029
+ By default, the `git push` command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches – you can run `git push origin [tagname]`.
1030
+
1031
+ $ git push origin v1.5
1032
+ Counting objects: 50, done.
1033
+ Compressing objects: 100% (38/38), done.
1034
+ Writing objects: 100% (44/44), 4.56 KiB, done.
1035
+ Total 44 (delta 18), reused 8 (delta 1)
1036
+ To git@github.com:schacon/simplegit.git
1037
+ * [new tag] v1.5 -> v1.5
1038
+
1039
+ If you have a lot of tags that you want to push up at once, you can also use the `--tags` option to the `git push` command. This will transfer all of your tags to the remote server that are not already there.
1040
+
1041
+ $ git push origin --tags
1042
+ Counting objects: 50, done.
1043
+ Compressing objects: 100% (38/38), done.
1044
+ Writing objects: 100% (44/44), 4.56 KiB, done.
1045
+ Total 44 (delta 18), reused 8 (delta 1)
1046
+ To git@github.com:schacon/simplegit.git
1047
+ * [new tag] v0.1 -> v0.1
1048
+ * [new tag] v1.2 -> v1.2
1049
+ * [new tag] v1.4 -> v1.4
1050
+ * [new tag] v1.4-lw -> v1.4-lw
1051
+ * [new tag] v1.5 -> v1.5
1052
+
1053
+ Now, when someone else clones or pulls from your repository, they will get all your tags as well.
1054
+
1055
+ ## Tips and Tricks ##
1056
+
1057
+ Before we finish this chapter on basic Git, a few little tips and tricks may make your Git experience a bit simpler, easier, or more familiar. Many people use Git without using any of these tips, and we won’t refer to them or assume you’ve used them later in the book; but you should probably know how to do them.
1058
+
1059
+ ### Auto-Completion ###
1060
+
1061
+ If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download the Git source code, and look in the `contrib/completion` directory; there should be a file called `git-completion.bash`. Copy this file to your home directory, and add this to your `.bashrc` file:
1062
+
1063
+ source ~/.git-completion.bash
1064
+
1065
+ If you want to set up Git to automatically have Bash shell completion for all users, copy this script to the `/opt/local/etc/bash_completion.d` directory on Mac systems or to the `/etc/bash_completion.d/` directory on Linux systems. This is a directory of scripts that Bash will automatically load to provide shell completions.
1066
+
1067
+ If you’re using Windows with Git Bash, which is the default when installing Git on Windows with msysGit, auto-completion should be preconfigured.
1068
+
1069
+ Press the Tab key when you’re writing a Git command, and it should return a set of suggestions for you to pick from:
1070
+
1071
+ $ git co<tab><tab>
1072
+ commit config
1073
+
1074
+ In this case, typing git co and then pressing the Tab key twice suggests commit and config. Adding `m<tab>` completes `git commit` automatically.
1075
+
1076
+ This also works with options, which is probably more useful. For instance, if you’re running a `git log` command and can’t remember one of the options, you can start typing it and press Tab to see what matches:
1077
+
1078
+ $ git log --s<tab>
1079
+ --shortstat --since= --src-prefix= --stat --summary
1080
+
1081
+ That’s a pretty nice trick and may save you some time and documentation reading.
1082
+
1083
+ ### Git Aliases ###
1084
+
1085
+ Git doesn’t infer your command if you type it in partially. If you don’t want to type the entire text of each of the Git commands, you can easily set up an alias for each command using `git config`. Here are a couple of examples you may want to set up:
1086
+
1087
+ $ git config --global alias.co checkout
1088
+ $ git config --global alias.br branch
1089
+ $ git config --global alias.ci commit
1090
+ $ git config --global alias.st status
1091
+
1092
+ This means that, for example, instead of typing `git commit`, you just need to type `git ci`. As you go on using Git, you’ll probably use other commands frequently as well; in this case, don’t hesitate to create new aliases.
1093
+
1094
+ This technique can also be very useful in creating commands that you think should exist. For example, to correct the usability problem you encountered with unstaging a file, you can add your own unstage alias to Git:
1095
+
1096
+ $ git config --global alias.unstage 'reset HEAD --'
1097
+
1098
+ This makes the following two commands equivalent:
1099
+
1100
+ $ git unstage fileA
1101
+ $ git reset HEAD fileA
1102
+
1103
+ This seems a bit clearer. It’s also common to add a `last` command, like this:
1104
+
1105
+ $ git config --global alias.last 'log -1 HEAD'
1106
+
1107
+ This way, you can see the last commit easily:
1108
+
1109
+ $ git last
1110
+ commit 66938dae3329c7aebe598c2246a8e6af90d04646
1111
+ Author: Josh Goebel <dreamer3@example.com>
1112
+ Date: Tue Aug 26 19:48:51 2008 +0800
1113
+
1114
+ test for current head
1115
+
1116
+ Signed-off-by: Scott Chacon <schacon@example.com>
1117
+
1118
+ As you can tell, Git simply replaces the new command with whatever you alias it for. However, maybe you want to run an external command, rather than a Git subcommand. In that case, you start the command with a `!` character. This is useful if you write your own tools that work with a Git repository. We can demonstrate by aliasing `git visual` to run `gitk`:
1119
+
1120
+ $ git config --global alias.visual '!gitk'
1121
+
1122
+ ## Summary ##
1123
+
1124
+ At this point, you can do all the basic local Git operations — creating or cloning a repository, making changes, staging and committing those changes, and viewing the history of all the changes the repository has been through. Next, we’ll cover Git’s killer feature: its branching model.