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

GIT

533 views

Published on

git

Published in: Software
  • Be the first to comment

GIT

  1. 1. Matt Harasymczuk GIT introduction
  2. 2. Matt Harasymczuk
  3. 3. Matt Harasymczuk
  4. 4. Matt Harasymczuk
  5. 5. Matt Harasymczuk
  6. 6. Matt Harasymczuk Key - Value
  7. 7. Matt Harasymczuk Branching is not the issue, the merging is... Linus Torvalds
  8. 8. Matt Harasymczuk
  9. 9. Matt Harasymczuk
  10. 10. Matt Harasymczuk
  11. 11. Matt Harasymczuk
  12. 12. Matt Harasymczuk
  13. 13. Matt Harasymczuk
  14. 14. Matt Harasymczuk Rename track discover
  15. 15. Matt Harasymczuk GIT hash
  16. 16. Matt Harasymczuk git remotes • git ls-remote • git gc --aggressive --prune=now • git remote update --prune • git remote -v
  17. 17. Matt Harasymczuk GitHub.com • create accounts • create repo • protect branches • add collaborators • clone & touch .gitignore & push • pull-request
  18. 18. Matt Harasymczuk GIT refs • .git/HEAD • .git/refs/heads/master • .git/refs/heads/* • .git/refs/remotes/* • .git/refs/tags/* • (HEAD detached at 44d11b0)
  19. 19. Matt Harasymczuk .git internals • ~/.gitconfig • .git/config • git config multiple url • .git/refs/* • .git/HEAD • .git/objects/* • .git/objects/pack/
  20. 20. Matt Harasymczuk .gitconfig [alias] • l = log --pretty=format:"%C(yellow)%h %ad%Cred%d %Creset%s%Cblue [%cn]" --decorate --date=short • again = "!f() { git add -A && git status && git commit -m "$(git log -1 -- format='%s')" && git push && git l -1; }; f" • d = diff --cached HEAD^
  21. 21. Matt Harasymczuk .gitconfig [i18n] commitencoding = UTF-8 logoutputencoding = UTF-8 [core] eol = 'lf' autocrlf = input excludesfile = /Users/matt/.gitignore_global [branch "master"] rebase = true [branch] #autosetuprebase = always [color] ui = true
  22. 22. Matt Harasymczuk
  23. 23. Matt Harasymczuk
  24. 24. Matt Harasymczuk
  25. 25. Matt Harasymczuk
  26. 26. Matt Harasymczuk
  27. 27. Matt Harasymczuk Scenariusz • github account • ssh-keygen • add ssh to profile (~/.ssh/id_rsa.pub) • share repository access with people • clone repository via ssh • add file inazwisko.txt • add user.email and user.name to gitconfig • amend & commit & push • pull request + uprawnienia + mergowanie
  28. 28. Matt Harasymczuk Rozpoczynanie pracy • git init • git init --bare • git clone URL [dest dir] • git clone file:///... • git clone ssh://... • git clone https://... • git clone --recursive URL
  29. 29. Matt Harasymczuk git branch • git branch • git branch inazwisko • git checkout inazwisko • git checkout -tb origin/master
  30. 30. Matt Harasymczuk git reset • git reset --hard • git reset --soft • git reset --mixed
  31. 31. Matt Harasymczuk git pull • git fetch • git merge or git rebase
  32. 32. Matt Harasymczuk git push • git push • git push --tags • git push --all • git push origin • git push origin master • git push origin master:inazwisko • git push origin :inazwisko
  33. 33. Matt Harasymczuk git stash • git stash [save] • git stash list • git stash pop vs. git stash apply • git stash drop • git stash clear • konflikty przy git stash apply
  34. 34. Matt Harasymczuk git tag • git tag -n1 • git tag --list • git describe • .git/refs/tags/* • git push --tags • git push origin <tag_name>
  35. 35. Matt Harasymczuk
  36. 36. Matt Harasymczuk History Manipulation
  37. 37. Matt HarasymczukMieszko I B. Chrobry Mieszko II K. Odnowiciel
  38. 38. Matt HarasymczukMieszko I B. Chrobry Mieszko II K. Odnowiciel
  39. 39. Matt HarasymczukMieszko I B. Chrobry Mieszko II K. Odnowiciel
  40. 40. Matt HarasymczukMieszko I B. ChrobryMieszko II K. Odnowiciel
  41. 41. Matt Harasymczuk Remove sensitive data FILENAME=”secret.txt” git filter-branch --index-filter 'git rm --cached --ignore-unmatch $FILENAME' --prune-empty -- --all http://help.github.com/remove-sensitive-data/
  42. 42. Matt Harasymczuk Change user or email git filter-branch --commit-filter ' if [ "$GIT_COMMITTER_NAME" = "flastname" ]; then GIT_COMMITTER_NAME="Firstname Lastname"; GIT_AUTHOR_NAME="Firstname Lastname"; GIT_COMMITTER_EMAIL="mateusz.harasymczuk@domain.tld"; GIT_AUTHOR_EMAIL="mateusz.harasymczuk@domain.tld"; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD
  43. 43. Matt Harasymczuk cherry-picking
  44. 44. Matt Harasymczuk
  45. 45. Matt Harasymczuk
  46. 46. Matt Harasymczuk
  47. 47. Matt Harasymczuk git merge
  48. 48. Matt Harasymczuk
  49. 49. Matt Harasymczuk
  50. 50. Matt Harasymczuk
  51. 51. Matt Harasymczuk rebase
  52. 52. Matt Harasymczuk
  53. 53. Matt Harasymczuk
  54. 54. Matt Harasymczuk
  55. 55. Matt Harasymczuk
  56. 56. Matt Harasymczuk
  57. 57. Matt Harasymczuk
  58. 58. Matt Harasymczuk rebase vs. merge
  59. 59. Matt Harasymczuk
  60. 60. Matt Harasymczuk git rebase -i • p, pick = use commit • r, reword = use commit, but edit the commit message • e, edit = use commit, but stop for amending • s, squash = use commit, but meld into previous commit • f, fixup = like "squash", but discard this commit's log message • x, exec = run command (the rest of the line) using shell • d, drop = remove commit
  61. 61. Matt Harasymczuk squash
  62. 62. Matt Harasymczuk pushed repo rebase • git push --force
  63. 63. Matt Harasymczuk GIT tools
  64. 64. Matt Harasymczuk
  65. 65. Matt Harasymczuk Workflow
  66. 66. Matt Harasymczuk git pull --rebase
  67. 67. Matt Harasymczuk git add
  68. 68. Matt Harasymczuk git rm
  69. 69. Matt Harasymczuk git mv
  70. 70. Matt Harasymczuk git commit
  71. 71. Matt Harasymczuk
  72. 72. Matt Harasymczuk git push
  73. 73. Matt Harasymczuk
  74. 74. Matt Harasymczuk git log • git log --oneline • git log --graph • git log -5 • git log -15 --oneline --graph • git log --format='%h %ae %s' • git log --format='"%H", "%an", "%ae", "%ad", "%s"' --date=iso > ~/Desktop/commits.csv • git log --format='%ad' --date=iso • git log --format='%ae' |sort |uniq
  75. 75. Matt Harasymczuk • git reflog
  76. 76. Matt Harasymczuk git status
  77. 77. Matt Harasymczuk git show
  78. 78. Matt Harasymczuk # changes in working directory git diff # changes between commits git diff ac04c72..5968eb9 git diff HEAD^
  79. 79. Matt Harasymczuk git submodule • git submodule add git@github.com:AstroTech/workshop-git lib/git-docs • git status • cat .gitmodules • git submodule init • git submodule update • git submodule rm lib/git-docs • Update submodułów • cd lib/git-docs • git pull • cd .. • git status • git commit
  80. 80. Matt Harasymczuk git subtree
  81. 81. Matt Harasymczuk git hooks • .git/hooks/pre-commit • chmod +x .git/hooks/pre-commit • #!/bin/sh • exit 0 # zmiana sie zapisze • exit 1 # kod bledu, nie zakomituje sie
  82. 82. Matt Harasymczukgit bisect and git blame
  83. 83. Matt Harasymczuk git rebase • git rebase -i HEAD~3 • git rebase -i HEAD^^^ • git rebase -i HEAD ~~~ • git rebase -i --root • (old version problem with rebase of first commit)
  84. 84. Matt Harasymczuk GIT gui tools • gitk • sourcetree • msysgit • tortoiseGIT
  85. 85. Matt Harasymczuk IDE • Eclipse • InteliJ • PyCharm • Webstorm • Rubymine • NetBeans
  86. 86. Matt Harasymczuk GIT repo hosting - cloud • Gitlab • Bitbucket Cloud • Github
  87. 87. Matt Harasymczuk GIT repo hosting - server • Gitlab • Bitbucket Server • Github Enterprise • Gitolite • Gitblit
  88. 88. Matt Harasymczuk CI / CD • circleCI • travis • bitbucket pipelines
  89. 89. Matt Harasymczuk ssh-keygen • vim ~/.ssh/id_rsa.pub • imie.nazwisko@domain.tld/hostname
  90. 90. Matt Harasymczuk GIT LFS
  91. 91. Matt Harasymczuk Strategies
  92. 92. Matt Harasymczuk Central Repository Model
  93. 93. Matt Harasymczuk
  94. 94. Matt Harasymczuk Cherry-picking Model
  95. 95. Matt Harasymczuk
  96. 96. Matt Harasymczuk
  97. 97. Matt Harasymczuk
  98. 98. Matt Harasymczuk
  99. 99. Matt Harasymczuk
  100. 100. Matt Harasymczuk
  101. 101. Matt Harasymczuk Army Model
  102. 102. Matt Harasymczuk
  103. 103. Matt Harasymczuk
  104. 104. Matt Harasymczuk
  105. 105. Matt Harasymczuk
  106. 106. Matt Harasymczuk
  107. 107. Matt Harasymczuk Modele pracy z GIT
  108. 108. Matt Harasymczuk GIT Flow • https://github.com/nvie/gitflow • http://nvie.com/posts/a-successful-git- branching-model/ • https://www.atlassian.com/git/tutorials/ comparing-workflows/gitflow-workflow
  109. 109. Matt Harasymczuk Feature branching model • https://www.atlassian.com/git/tutorials/ comparing-workflows/feature-branch- workflow
  110. 110. Matt Harasymczuk Forking Workflow • https://www.atlassian.com/git/tutorials/ comparing-workflows/forking-workflow
  111. 111. Matt Harasymczuk Usecase
  112. 112. Matt Harasymczuk allegro release
  113. 113. Matt Harasymczuk allegro test env
  114. 114. Matt Harasymczuk pull request
  115. 115. Matt Harasymczuk Markdown • # naglowek 1 poziomu • ## naglowek 2 poziomu • ### naglowek 3 poziomu • [Opis](http://example.com/) • ![Opis](http://example.com/img.jpg) • `code` • *em* i **strong** • Tabelki • Listy • numerowane • nieuporządkowane • zagnieżdżone
  116. 116. Matt Harasymczuk Przydatne URL • https://github.com/AstroTech/workshop-git/ • https://www.atlassian.com/git/ • https://travis.org • https://bitbucket.org • http://git-scm.com
  117. 117. Matt Harasymczuk lolcommits • lolcommits --enable • lolcommits --disable
  118. 118. Matt Harasymczuk Conclusion
  119. 119. Matt Harasymczuk Why DVCS?
  120. 120. Matt Harasymczuk Why GIT?
  121. 121. Matt Harasymczuk
  122. 122. Matt Harasymczuk
  123. 123. Matt Harasymczuk
  124. 124. Matt Harasymczuk Ask me about your problem :}

×