version control with git
play

Version Control with git or: Why you dont want to live without it! - PowerPoint PPT Presentation

W ESTFLISCHE W ILHELMS -U NIVERSITT M NSTER Version Control with git or: Why you dont want to live without it! living knowledge WWU Mnster October 15th, 2014 W ESTFLISCHE W ILHELMS -U NIVERSITT M NSTER Version Control with git


  1. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git or: Why you don’t want to live without it! living knowledge WWU Münster October 15th, 2014

  2. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 2 /21 Why Version Control? ◮ “I do backups already!” ◮ “I already use dropbox to share my work.” ◮ “Is git not used by the linux kernel...” Aka: “... by people much smarter, thus it’s way to complicated for me?” living knowledge ◮ “I’m just working alone on a small project...” WWU Münster , , felix.schindler@wwu.de

  3. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 3 /21 Why Version Control? Live Demo: small L A T EX project living knowledge WWU Münster , , felix.schindler@wwu.de

  4. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 4 /21 outline Why Version Control? Working with an existing project living knowledge Rewriting history WWU Münster other nice stuff , , felix.schindler@wwu.de

  5. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 5 /21 Why Version Control? You can easily keep track of your work, examine changes, ... ◮ git init , git add , git commit ◮ git status , git log , git diff [--word-diff] living knowledge ◮ git gui , gitk WWU Münster , , felix.schindler@wwu.de

  6. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? living knowledge WWU Münster [F ROM : http://git-scm.com/book/ ] , , felix.schindler@wwu.de

  7. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? living knowledge WWU Münster [F ROM : http://git-scm.com/book/ ] , , felix.schindler@wwu.de

  8. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? living knowledge WWU Münster [F ROM : http://git-scm.com/book/ ] , , felix.schindler@wwu.de

  9. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? living knowledge WWU Münster [F ROM : http://git-scm.com/book/ ] , , felix.schindler@wwu.de

  10. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? by keeping SHA1 hashes of everything living knowledge WWU Münster , , felix.schindler@wwu.de

  11. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 6 /21 How does git work? by keeping SHA1 hashes of everything ⇒ git ensures consistency! living knowledge WWU Münster , , felix.schindler@wwu.de

  12. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 7 /21 outline Why Version Control? Working with an existing project living knowledge Rewriting history WWU Münster other nice stuff , , felix.schindler@wwu.de

  13. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 8 /21 Working with an existing project Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  14. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 8 /21 Working with an existing project Old school: sending a patch ◮ git clone https://github.com/pymor/pymor.git ◮ ... do your changes... living knowledge ◮ git format-patch -M origin/master WWU Münster , , felix.schindler@wwu.de

  15. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 9 /21 Working with an existing project Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  16. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 9 /21 Working with an existing project Fork it ◮ git clone https://github.com/pymor/pymor.git ◮ ... do your changes... ◮ git remote add personal https://my-repo.org/pymor.git living knowledge ◮ git push personal master WWU Münster ◮ request a pull from your repository , , felix.schindler@wwu.de

  17. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 10 /21 Working with an existing project Fork it on github.com If the project is hosted on github.com (or equivalent sites) ◮ create a login ◮ “fork” the repository (creates a new copy of the repository belonging to you) living knowledge ◮ ... do your changes... ◮ push your changes in a feature branch WWU Münster ◮ create a pull request , , felix.schindler@wwu.de

  18. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 11 /21 Working with an existing project git is distributed ◮ your local copy contains the complete repository (including the history) ◮ no single point of failure living knowledge ◮ “automatic” backups WWU Münster , , felix.schindler@wwu.de

  19. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 12 /21 outline Why Version Control? Working with an existing project living knowledge Rewriting history WWU Münster other nice stuff , , felix.schindler@wwu.de

  20. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 13 /21 Rewriting history changing the latest commit Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  21. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 13 /21 Rewriting history changing the latest commit ◮ git commit --amend ◮ creates a new commit living knowledge ⇒ should only be used before pushing WWU Münster , , felix.schindler@wwu.de

  22. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 14 /21 Rewriting history changing several commits Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  23. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 14 /21 Rewriting history changing several commits ◮ git rebase -i HEAD N ◮ rewrites the last N commits living knowledge ⇒ should only be used in your personal repo WWU Münster , , felix.schindler@wwu.de

  24. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 15 /21 Rewriting history systematical changes Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  25. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 15 /21 Rewriting history systematical changes ◮ git filter-branch --tree-filter ’rm -f *.pdf’ HEAD ◮ rewrites the complete history ⇒ should only be used very rarely with proper preparation living knowledge ◮ other possibilities ◮ change tab width in all commits WWU Münster ◮ change name/mail of author ◮ whatever fits between ’ ... ’ , , felix.schindler@wwu.de

  26. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 16 /21 Rewriting history There is no git push --force How to publish a rewritten history? ⇒ Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  27. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 16 /21 Rewriting history There is no git push --force How to publish a rewritten history? ⇒ don’t! living knowledge WWU Münster , , felix.schindler@wwu.de

  28. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 16 /21 Rewriting history There is no git push --force How to publish a rewritten history? ⇒ don’t! But if you need to: git push --force living knowledge WWU Münster , , felix.schindler@wwu.de

  29. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 16 /21 Rewriting history There is no git push --force How to publish a rewritten history? ⇒ don’t! But if you need to: git push --force living knowledge ◮ may be OK for amend (within 60 seconds) ◮ not OK for rebase -i WWU Münster ◮ for filter-branch only with consent of all authors , , felix.schindler@wwu.de

  30. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 17 /21 outline Why Version Control? Working with an existing project living knowledge Rewriting history WWU Münster other nice stuff , , felix.schindler@wwu.de

  31. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 18 /21 other nice stuff find the hidden documentation Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  32. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 18 /21 other nice stuff find the hidden documentation git show $(git blame header.hh -L N,N | awk ’{print $1}’) living knowledge WWU Münster , , felix.schindler@wwu.de

  33. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 19 /21 other nice stuff find problematic design Live Demo living knowledge WWU Münster , , felix.schindler@wwu.de

  34. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 19 /21 other nice stuff find problematic design ◮ download git-churn : https://github.com/garybernhardt/dotfiles/blob/ f0c0ff92209e5aed4fa3ef6faf056eb9944a8f12/bin/git-churn living knowledge ◮ git churn --since=’6 months ago’ path/ | tail WWU Münster , , felix.schindler@wwu.de

  35. W ESTFÄLISCHE W ILHELMS -U NIVERSITÄT M ÜNSTER Version Control with git 20 /21 resources ◮ http://git-scm.com/book ◮ https://try.github.io ◮ http://mislav.uniqpath.com living knowledge ◮ http://www.google.com WWU Münster , , felix.schindler@wwu.de

Recommend


More recommend