Advertisement
Guest User

Untitled

a guest
Mar 5th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. #### git is awesome! Will do some live demos.<br/>Bring your problems, I'll try to solve them!
  2.  
  3. ---
  4.  
  5. # Yep, `git`.
  6.  
  7. ---
  8.  
  9. ## I am @jacquesbh
  10.  
  11. ### Magento Firefighter
  12.  
  13. ### Tools lover
  14.  
  15. ### Founder of @MonsieurBiz
  16.  
  17. ### Board member of the French PHP Group "AFUP"
  18.  
  19. ---
  20.  
  21. # What is git?
  22.  
  23. ---
  24.  
  25. # `git` is a Version Control System
  26.  
  27. ---
  28.  
  29. # That's it?
  30.  
  31. ---
  32.  
  33. # [fit] NOPE.
  34.  
  35. ---
  36.  
  37. # `git` is:
  38.  
  39. * A tree, with branches
  40. * A logger
  41. * A cloner
  42. * A conflicts recorder
  43. * A crazy tool
  44. * A "doer" for many things…
  45.  
  46. ---
  47.  
  48. # With `git` you can really do more than you think.
  49.  
  50. ---
  51.  
  52. ## We're going to use:
  53.  
  54. * The Command Line
  55. * and SourceTree (because it's easier)
  56.  
  57. ---
  58.  
  59. ```
  60. man git
  61. git-cherry-pick(1)
  62. Apply the changes introduced by some existing commits.
  63.  
  64. git-citool(1)
  65. Graphical alternative to git-commit.
  66.  
  67. git-clean(1)
  68. Remove untracked files from the working tree.
  69.  
  70. git-clone(1)
  71. Clone a repository into a new directory.
  72. ```
  73.  
  74. ---
  75.  
  76. # [fit] `git log`
  77.  
  78. ---
  79.  
  80. ###### demo
  81.  
  82. Basics:
  83.  
  84. ```bash
  85. $ git log
  86. commit 2af6081e23531d11a19c6a2f707f26835b9ac37f
  87. Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
  88. Date: Fri Feb 3 16:18:07 2017 -0500
  89.  
  90. magic, have no clue but it works
  91.  
  92. Notes:
  93. Yep, this is a note.
  94.  
  95. commit bb21d532a06aab4631ddb9d26b421ec390c953a8
  96. Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
  97. Date: Fri Feb 3 16:05:13 2017 -0500
  98.  
  99. magic, have no clue but it works
  100. ```
  101.  
  102. ---
  103.  
  104. When you sign your commits:
  105.  
  106. ```bash
  107. $ git log --show-signature
  108. commit 2af6081e23531d11a19c6a2f707f26835b9ac37f
  109. gpg: Signature made Fri Feb 3 16:18:07 2017 EST
  110. gpg: using RSA key CD2C5D48C181EBE4
  111. gpg: Good signature from "Jacques Bodin-Hullin <jacques@bodin-hullin.net>" [unknown]
  112. gpg: aka "Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>" [unknown]
  113. gpg: WARNING: This key is not certified with a trusted signature!
  114. gpg: There is no indication that the signature belongs to the owner.
  115. Primary key fingerprint: DEB8 A04A 7CB9 5FD7 57E8 B1A0 5B80 3023 D40A 0F67
  116. Subkey fingerprint: 8A45 FB3F 7E49 DE2F 907F E174 CD2C 5D48 C181 EBE4
  117. Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
  118. Date: Fri Feb 3 16:18:07 2017 -0500
  119.  
  120. magic, have no clue but it works
  121.  
  122. Notes:
  123. Yep, this is a note.
  124. ```
  125.  
  126. ---
  127.  
  128. ### What about a more complex log? Like a tree?
  129.  
  130. ```
  131. $ git log --graph --all --format=format:'%C(bold blue)%h%C(reset) \
  132. - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) \
  133. %C(bold white)- %an%C(reset)%C(bold yellow)%d%C(reset)' \
  134. --abbrev-commit --date=relative --color=always -15
  135. ```
  136.  
  137. ---
  138.  
  139. # [fit] `git rebase -i`
  140.  
  141. ---
  142.  
  143. ###### demo
  144.  
  145.  
  146. ```bash
  147. $ git checkout foo
  148. ```
  149.  
  150. Then add commits and perform a rebase on `origin/foo`.
  151.  
  152. ---
  153.  
  154. # [fit] `git cherry-pick`
  155.  
  156. ---
  157.  
  158. ###### demo
  159.  
  160.  
  161. ```bash
  162. $ git cherry-pick 1bf6d18dd
  163. [cherry-pick dbe74eb] Useful text
  164. Date: Fri Feb 3 16:04:36 2017 -0500
  165. 1 file changed, 1 insertion(+)
  166. create mode 100644 file8.txt
  167. ```
  168.  
  169. ---
  170.  
  171. ## What happen if I rebase a branch on another with some identical commits?
  172.  
  173. The duplicated commits disappear!
  174.  
  175. ---
  176.  
  177. # [fit] `git worktree`
  178.  
  179. ---
  180.  
  181. ###### demo
  182.  
  183.  
  184. ```bash
  185. $ git worktree add ../fix-stuff
  186. ```
  187.  
  188. ---
  189.  
  190. # [fit] `git reflog`
  191.  
  192. ---
  193.  
  194. ###### demo
  195.  
  196.  
  197. ```bash
  198. $ git reflog
  199. 5098179 HEAD@{0}: reset: moving to master
  200. 977f91e HEAD@{1}: checkout: moving from cherry-pick to cherry-pick2
  201. 5098179 HEAD@{2}: reset: moving to master
  202. 977f91e HEAD@{3}: rebase finished: returning to refs/heads/cherry-pick
  203. 977f91e HEAD@{4}: rebase: checkout cherry-pick2
  204. 70dcd89 HEAD@{5}: reset: moving to HEAD
  205. 70dcd89 HEAD@{6}: cherry-pick: It compiles! Ship it!
  206. 5098179 HEAD@{7}: checkout: moving from cherry-pick2 to cherry-pick
  207. ```
  208.  
  209. ---
  210.  
  211. # [fit] `git clean`
  212.  
  213. ---
  214.  
  215. ###### demo
  216.  
  217. ```
  218. $ git clean -i
  219. Would remove the following items:
  220. file30.txt file31.txt file32.txt file33.txt
  221. *** Commands ***
  222. 1: clean 2: filter by pattern 3: select by numbers 4: ask each 5: quit 6: help
  223. What now> 4
  224. Remove file30.txt [y/N]?
  225. Remove file31.txt [y/N]?
  226. Remove file32.txt [y/N]? y
  227. Remove file33.txt [y/N]?
  228. Removing file32.txt
  229. ```
  230.  
  231. ---
  232.  
  233. ```
  234. $ git clean -df
  235. ```
  236.  
  237. ---
  238.  
  239. # [fit] `git bisect`
  240.  
  241. ---
  242.  
  243. ###### demo
  244.  
  245.  
  246. ```bash
  247. $ g bisect bad
  248. 2c0d770dda8ce3b00c1756a09cacc6677fcc238b is the first bad commit
  249. commit 2c0d770dda8ce3b00c1756a09cacc6677fcc238b
  250. Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
  251. Date: Fri Feb 3 16:58:32 2017 -0500
  252.  
  253. MOAR BIFURCATION
  254.  
  255. :100644 100644 39bf59e13… 8d94e8e37f… M index.php
  256. ```
  257.  
  258. ---
  259.  
  260. # [fit] `git notes`
  261.  
  262. ---
  263.  
  264. ###### demo
  265.  
  266.  
  267. ```bash
  268. $ git notes add -m "CI PASS"
  269. $ git push origin refs/notes/commits
  270. ```
  271.  
  272. ---
  273.  
  274. # [fit] `git remote prune origin`
  275.  
  276. ---
  277.  
  278. ###### demo
  279.  
  280.  
  281. ```bash
  282. $ git remote prune origin
  283. Pruning origin
  284. URL: git@github.com:monsieurbiz/talk-git-sunphp17.git
  285. * [pruned] origin/bob
  286. ```
  287.  
  288. ---
  289.  
  290. # [fit] `git check-ignore`
  291.  
  292. ---
  293.  
  294. ###### demo
  295.  
  296.  
  297. ```bash
  298. $ echo file100.txt > .gitignore
  299. $ # …
  300. $ git check-ignore *
  301. file100.txt
  302.  
  303. ```
  304.  
  305. ---
  306.  
  307. # [fit] `git rerere`
  308.  
  309. ---
  310.  
  311. ### Usually when "control MERGE"
  312.  
  313. ```bash
  314. $ git config --global rerere.enabled true
  315. ```
  316.  
  317. ---
  318.  
  319. # Tip: aliases!
  320.  
  321. ---
  322.  
  323. ### Some of mine…
  324.  
  325. ```bash
  326. $ git br
  327. $ git tr
  328. $ git ci
  329. $ git cp
  330. $ git cn
  331. $ git rb
  332. $ git rod
  333. $ git rodd
  334. ```
  335.  
  336. ---
  337.  
  338. # Tip: `tig`
  339.  
  340. ---
  341.  
  342.  
  343. # What about your problems?
  344.  
  345. * `log`, `rebase`
  346. * `cherry-pick`, `worktree`
  347. * `reflog`, `clean`
  348. * `bisect`, `notes`
  349. * `remote prune`, `check-ignore`
  350. * `rerere` and `tig`
  351.  
  352. ---
  353.  
  354. # [fit] Thanks!
  355.  
  356. ---
  357.  
  358. ## How to sign your commit?
  359.  
  360. ```
  361. $ git config --global commit.gpgsign true
  362. $ git config --global user.signingkey D40A4467
  363. ```
  364.  
  365. ---
  366.  
  367. # You can change the GPG programm too
  368.  
  369. ```
  370. $ git config --global gpg.program /Users/jacques/bin/git/gpg
  371. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement