Git Workflows

Git Workflows

7a0e72a6f55811246bb5d9a946fd2e49?s=128

Radoslav Stankov

October 19, 2018
Tweet

Transcript

  1. Radoslav Stankov 18/10/2018 Improving Your Workflows

  2. Radoslav Stankov @rstankov blog.rstankov.com github.com/rstankov
 twitter.com/rstankov

  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. = !

  13. None
  14. None
  15. None
  16. None
  17. None
  18. Git: Under the hooh

  19. cd .git

  20. refs/ objects/ logs/ hooks/ index HEAD config COMMIT_EDITMSG

  21. refs/ objects/ logs/ hooks/ index HEAD config COMMIT_EDITMSG

  22. "Git just object database + some shell scripts"

  23. None
  24. Content

  25. Content Type + ' ' + Size + \0 Content

  26. Content Type + ' ' + Size + \0 Content

    SHA1 digest
 bbd51c3fa6ccabc8e3bf955958...
  27. Content Type + ' ' + Size + \0 Content

    SHA1 digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f
  28. Content Type + ' ' + Size + \0 Content

    SHA1 digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f
  29. Content Type + ' ' + Size + \0 Content

    SHA1 digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f
  30. bbd51c bbd51c3fa bbd51c3fa6ccab bbd51c3fa6ccabc8e3bf95 bbd51c3fa6ccabc8e3bf9559cd0af21558995d3f 
 .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f


  31. Commit Tree Blob 
 Main Object Types


  32. Commit Tree Blob 
 Main Object Types


  33. 
 Blob


  34. 
 Blob
 export function toggleTopicFollow(topicId: number): Dispatchable { return function(dispatch:

    Dispatch, getState: Function, api: any): void { const { currentUser } = getState(); if (isFollowingTopic(currentUser, id)) { api.topics.followers.delete({ topicId }); dispatch({ type: UNFOLLOW_TOPIC, payload: { topicId } }); } else { api.topics.followers.create({ topicId }); dispatch({ type: FOLLOW_TOPIC, payload: { topicId } }); } }; }
  35. Commit Tree Blob 
 Main Object Types


  36. 
 Tree
 client/ server/ README.md

  37. 
 Tree
 Tree Blob (/README.md) Tree (/client/) Tree (/server/)

  38. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ 
 Tree

  39. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ mode 
 Tree

  40. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ 
 Tree

  41. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ type 
 Tree

  42. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ 
 Tree

  43. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ ref 
 Tree

  44. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ 
 Tree

  45. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ name 
 Tree

  46. Tree 100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README.md 040000 blob 8f94139338f9404f26296befa88755fc2598c289 client/ 040000

    tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 server/ 
 Tree

  47. Commit Tree Blob 
 Main Object Types


  48. 
 Commit


  49. 
 Commit
 Tree Blob (/README.md) Tree (/client/) Tree (/server/)

  50. 
 Commit
 Tree Blob (/README.md) Tree (/client/) Tree (/server/)

  51. 
 Commit
 Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit

  52. 
 Commit
 Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit

    Commit
 (parent)
  53. Commit Tree a906cb2a4a904a152e80877d4088654daad0c859 Parent 8f94139338f9404f26296befa88755fc2598c289 Author Radoslav Stankov <me@rstankov.com> 123242

    Date Sat May 5 18:09:34 2018 -0700 
 Commit

  54. Commit Tree Blob 
 Main Object Types


  55. Commit Tree Blob 
 Main Object Types


  56. Commit Tree Blob 
 Main Object Types


  57. Commit Tree Blob 
 Main Object Types


  58. Commit Tree Blob 
 Main Object Types


  59. Content Type + ' ' + Size + \0 Content

    SHA1 digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f
  60. Type + ' ' + Size + \0 Content SHA1

    digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f Commit Tree Blob
  61. Type + ' ' + Size + \0 Content SHA1

    digest
 bbd51c3fa6ccabc8e3bf955958... .git/objects/bb/d51c3fa6ccabc8e3bf9559cd0af21558995d3f Commit Tree Blob
  62. Commit Tree Blob 
 Main Object Types


  63. Commit Tree Blob 
 Main Object Types


  64. refs/ objects/ logs/ hooks/ index HEAD config COMMIT_EDITMSG

  65. refs/ objects/ logs/ hooks/ index HEAD config COMMIT_EDITMSG

  66. "Refs are basically pointers to commit"

  67. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit

  68. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit

  69. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (mater)

  70. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (HEAD)

    Ref
 (mater)
  71. Tag 
 (v1) Tree Blob (/README.md) Tree (/client/) Tree (/server/)

    Commit Ref
 (HEAD) Ref
 (mater)
  72. Tag 
 (v1) Ref
 (remote/master) Tree Blob (/README.md) Tree (/client/)

    Tree (/server/) Commit Ref
 (HEAD) Ref
 (mater)
  73. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (mater)

    Tag 
 (v1) Ref
 (remote/master) Ref
 (HEAD)
  74. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (HEAD)

    Ref
 (mater)
  75. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (HEAD)

  76. Tree Blob (/README.md) Tree (/client/) Tree (/server/) Commit Ref
 (HEAD)

    Commit Tree Blob (/README.md)
  77. Tree Tree (/client/) Tree (/server/) Commit Ref
 (HEAD) Commit Tree

    Blob (/README.md) Commit Tree
  78. None
  79. git clone git add git commit git status git fetch

    git push git pull git checkout git branch git log
 git diff 
 Main Git Commands

  80. 
 Main Git Commands
 Remote Local Staging Unstaged

  81. 
 Main Git Commands
 Remote Local Staging Unstaged git add

  82. 
 Main Git Commands
 Remote Local Staging Unstaged git add

    git commit
  83. 
 Main Git Commands
 Remote Local Staging Unstaged git add

    git commit git push
  84. 
 Main Git Commands
 Remote Local Staging Unstaged git add

    git commit git push git pull
  85. 
 Main Git Commands
 Remote Local Staging Unstaged git add

    git commit git push git pull git checkout
  86. refs/ objects/ logs/ hooks/ index HEAD config COMMIT_EDITMSG

  87. Merge Rebase

  88. Master Commit M1

  89. Master Commit M1 Commit M2 Commit M3

  90. Master Branch Commit M1 Commit M2 Commit M3

  91. Master Branch Commit M1 Commit M2 Commit M3 Commit M4

  92. Master Branch Commit M1 Commit M2 Commit M3 Commit M4

    Commit B1
  93. Master Branch Commit M1 Commit M2 Commit M3 Commit M4

    Commit B1 Commit B2 Commit B3 Commit B4
  94. Master Branch Commit M1 Commit M2 Commit M3 Commit M4

    Commit M5 Commit M6 Commit B1 Commit B2 Commit B3 Commit B4
  95. 
 git merge [branch]
 Master Branch Commit M1 Commit M2

    Commit M3 Commit M4 Commit M5 Commit M6 Merge Commit Commit B1 Commit B2 Commit B3 Commit B4
  96. Master Branch Commit M1 Commit M2 Commit M3 Commit M4

    Commit M5 Commit M6 Commit B1 Commit B2 Commit B3 Commit B4 
 git rebase master [branch]

  97. Branch Master Commit M1 Commit M2 Commit M3 Commit M4

    Commit M5 Commit M6 Commit B1 Commit B2 Commit B3 Commit B4 
 git rebase master [branch]

  98. Branch Master Commit M5 Commit M6 Commit B1 Commit B2

    Commit B3 Commit B4 
 git rebase master [branch]

  99. Branch Master Commit M5 Commit M6 Commit B1 Commit B2

    Commit B3 Commit B4 
 git rebase master [branch]

  100. Branch Master Commit M5 Commit M6 Commit B1x Commit B2

    Commit B3 Commit B4 
 git rebase master [branch]

  101. Branch Master Commit M5 Commit M6 Commit B1x Commit B2x

    Commit B3x Commit B4x 
 git rebase master [branch]

  102. Branch Master Commit M5 Commit M6 Commit B1x Commit B2x

    Commit B3x Commit B4x 
 git merge [branch] 

  103. Improve your tools

  104. ~/.gitconfig

  105. [alias] st = status br = branch co = checkout

    
 https://github.com/RStankov/config_files/blob/master/dot/gitconfig

  106. [alias] stahs = stash puhs = push hsow = show

    
 https://github.com/RStankov/config_files/blob/master/dot/gitconfig

  107. [alias] stahs = stash puhs = push hsow = show

    
 https://github.com/RStankov/config_files/blob/master/dot/gitconfig
 "
  108. alias ga="git add -A" alias gp="git pull --rebase" alias grc="git

    add .; git rebase --continue" alias gr="git rebase -i" alias gs="git stash" alias gco="git checkout" alias gl="git lol" alias gd="git diff" alias gdc="git diff --cached" alias gst="git status" 
 https://github.com/RStankov/config_files/blob/master/dot/zsh/aliases

  109. [alias] ls = ls-files undo = reset --soft HEAD^ amend

    = commit --amend unstage = reset HEAD 
 https://github.com/RStankov/config_files/blob/master/dot/gitconfig

  110. [alias] lol = log --graph --decorate -- pretty='format:%C(yellow)%h%Cgreen%d%Creset %s %C(white)

    (%an, %ar)%Creset' --abbrev- commit today = log --stat --since='1 Day Ago' -- graph --pretty=oneline --abbrev-commit -- date=relative 
 https://github.com/RStankov/config_files/blob/master/dot/gitconfig

  111. 
 git lol


  112. 
 git today


  113. ~/bin/git-***

  114. ~/bin/git-pull-request

  115. 
 https://github.com/RStankov/config_files/blob/master/bin/git-pull-request
 #!/bin/bash current_branch=`git rev-parse --abbrev-ref HEAD` remote_url=`git remote get-url

    origin | awk '{gsub(/ git@github.com:/,"")}1' | awk '{gsub(/\.git/,"")}1'` git push origin $current_branch --set-upstream open https://github.com/$remote_url/compare/$current_branch 
 git pull-request

  116. ~/bin/rebase-on-master

  117. 
 https://github.com/RStankov/config_files/blob/master/bin/git-rebase-on-master
 #!/bin/bash current_branch=`git rev-parse --abbrev-ref HEAD` git checkout master

    git pull origin master --rebase git rebase master $current_branch 
 git rebase-on-master

  118. ~/bin/delete-merged

  119. 
 https://github.com/RStankov/config_files/blob/master/bin/git-delete-merged
 #!/bin/bash current_branch=`git rev-parse --abbrev-ref HEAD` git checkout master

    git pull origin master --rebase git rebase master $current_branch 
 git delete-merged

  120. GUI

  121. 
 Fork
 
 https://git-fork.com


  122. 
 https://git-fork.com


  123. "I only use Git GUI to stage files to commits

    and amending previous commits"
  124. 
 https://git-fork.com


  125. 
 https://git-fork.com


  126. None
  127. Thanks #