Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Commandless Git

Commandless Git

Having a basic understanding of how Git works is the key to taking the most out of it.

Alex Tercete

April 07, 2015
Tweet

More Decks by Alex Tercete

Other Decks in Programming

Transcript

  1. – Hash is generated for the file’s content – Generated

    hash is the same for identical inputs – Files are saved to the files database – Changes are added to the staging area Add
  2. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    c3 ed path/to/A.txt path/to/B.txt Hash generation SHA1 ca c3 ed
  3. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    c3 ed path/to/A.txt path/to/B.txt Hash generation SHA1 ca c3 ed path/to/A.txt path/to/B.txt c3 ed Commit ca
  4. c3 ed Files database Working directory Staging area Commit ca

    path/to/A.txt path/to/B.txt path/to/A.txt path/to/B.txt c3 ed Commits tree ca
  5. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt path/to/B.txt other/path/to/C.txt 17 2b 17 2b
  6. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt path/to/B.txt other/path/to/C.txt 17 2b 17 2b Hash generation SHA1 c3 17 7b 2b ca path/to/A.txt path/to/B.txt c3 17 Commit 7b other/path/to/C.txt 2b
  7. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt 17 2b path/to/A.txt path/to/B.txt c3 17 Commit 7b other/path/to/C.txt 2b 7b
  8. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt 17 2b 7b other/path/to/C.txt 6d 6d
  9. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt 17 2b 7b other/path/to/C.txt 6d 6d Hash generation SHA1 c3 17 6d path/to/A.txt path/to/B.txt c3 17 Commit 33 other/path/to/C.txt 6d 33 7b
  10. c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt

    Commits tree ca other/path/to/C.txt 17 2b 7b 6d 33
  11. – Hash is generated combining • Hash of the parent

    commit • Hashes of the files in the commit – Points to every file tracked by the repository – Staging area is cleared after the commit – Gets added to the commits tree Commit
  12. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 Branch
  13. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33
  14. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33
  15. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33
  16. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33
  17. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33 8e
  18. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33 8e 4c
  19. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c
  20. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c
  21. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c ff
  22. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c ff 54
  23. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
  24. – HEAD indicates the current commit being pointed to –

    There is nothing special about master – When on a branch, the reference gets updated after a commit Branch
  25. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54 Checkout
  26. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
  27. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
  28. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
  29. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
  30. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
  31. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
  32. c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree

    ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
  33. – Only HEAD moves – Files are copied from the

    files database into the working directory – Files database remains unaltered – Commits tree remains unaltered Checkout
  34. Files database Commits tree ca 7b 33 References HEAD 54

    master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff Merge
  35. Files database Commits tree ca 7b 33 References HEAD 54

    master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff
  36. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff
  37. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  38. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Merge NO CONFLICTS
  39. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  40. Files database Commits tree ca 7b 33 References HEAD 2f

    master 2f feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 2f
  41. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Merge WITH CONFLICTS
  42. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  43. Files database Commits tree ca 7b 33 References HEAD b5

    master b5 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 57 b5
  44. – Brings changes from other branch into current branch –

    Conflict resolution is done once – Commit has two parents Merge
  45. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Rebase NO CONFLICTS
  46. Files database Commits tree ca 7b 33 References HEAD e6

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  47. Files database Commits tree ca 7b 33 References HEAD 54

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  48. Files database Commits tree ca 7b 33 References HEAD a2

    master e6 feature/something 54 a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 54
  49. Files database Commits tree ca 7b 33 References HEAD 9f

    master e6 feature/something 54 a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 9f 54
  50. Files database Commits tree ca 7b 33 References HEAD 9f

    master e6 feature/something 9f a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 9f 54
  51. Files database Commits tree ca 7b 33 References HEAD 54

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Rebase WITH CONFLICTS
  52. Files database Commits tree ca 7b 33 References HEAD 54

    master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
  53. Files database Commits tree ca 7b 33 References HEAD dd

    master e6 feature/something 54 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f
  54. Files database Commits tree ca 7b 33 References HEAD b8

    master e6 feature/something 54 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f b8
  55. Files database Commits tree ca 7b 33 References HEAD b8

    master e6 feature/something b8 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f b8
  56. – Puts changes introduced by current branch onto other branch

    – Conflict resolution is done for each commit – No extra commits are made Rebase
  57. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Push
  58. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin
  59. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree
  60. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33
  61. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d
  62. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33
  63. – There is nothing special about origin – Tracking branch

    gets updated before uploading data to the remote – The remote is just another repository Push
  64. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 Fetch
  65. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33
  66. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa
  67. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa
  68. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa 62 b0
  69. Files database Commits tree ca 7b 33 References HEAD 33

    master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master b0 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa 62 b0
  70. – Tracking branch gets updated after downloading data from the

    remote – Merge or rebase can be performed afterwards Fetch