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

version control with git
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Version Control with git

  • r: Why you don’t want to live without it!

October 15th, 2014

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

slide-2
SLIDE 2

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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?”

◮ “I’m just working alone on a small project...”

, , felix.schindler@wwu.de

slide-3
SLIDE 3

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 3 /21

Why Version Control?

Live Demo: small L

AT

EX project

, , felix.schindler@wwu.de

slide-4
SLIDE 4

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 4 /21

  • utline

Why Version Control? Working with an existing project Rewriting history

  • ther nice stuff

, , felix.schindler@wwu.de

slide-5
SLIDE 5

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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] ◮ git gui, gitk

, , felix.schindler@wwu.de

slide-6
SLIDE 6

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

[FROM: http://git-scm.com/book/]

, , felix.schindler@wwu.de

slide-7
SLIDE 7

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

[FROM: http://git-scm.com/book/]

, , felix.schindler@wwu.de

slide-8
SLIDE 8

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

[FROM: http://git-scm.com/book/]

, , felix.schindler@wwu.de

slide-9
SLIDE 9

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

[FROM: http://git-scm.com/book/]

, , felix.schindler@wwu.de

slide-10
SLIDE 10

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

by keeping SHA1 hashes of everything

, , felix.schindler@wwu.de

slide-11
SLIDE 11

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 6 /21

How does git work?

by keeping SHA1 hashes of everything ⇒ git ensures consistency!

, , felix.schindler@wwu.de

slide-12
SLIDE 12

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 7 /21

  • utline

Why Version Control? Working with an existing project Rewriting history

  • ther nice stuff

, , felix.schindler@wwu.de

slide-13
SLIDE 13

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 8 /21

Working with an existing project

Live Demo

, , felix.schindler@wwu.de

slide-14
SLIDE 14

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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... ◮ git format-patch -M origin/master

, , felix.schindler@wwu.de

slide-15
SLIDE 15

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 9 /21

Working with an existing project

Live Demo

, , felix.schindler@wwu.de

slide-16
SLIDE 16

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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 ◮ git push personal master ◮ request a pull from your repository

, , felix.schindler@wwu.de

slide-17
SLIDE 17

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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) ◮ ... do your changes... ◮ push your changes in a feature branch ◮ create a pull request

, , felix.schindler@wwu.de

slide-18
SLIDE 18

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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 ◮ “automatic” backups

, , felix.schindler@wwu.de

slide-19
SLIDE 19

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 12 /21

  • utline

Why Version Control? Working with an existing project Rewriting history

  • ther nice stuff

, , felix.schindler@wwu.de

slide-20
SLIDE 20

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 13 /21

Rewriting history

changing the latest commit

Live Demo

, , felix.schindler@wwu.de

slide-21
SLIDE 21

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 13 /21

Rewriting history

changing the latest commit

◮ git commit --amend ◮ creates a new commit

⇒ should only be used before pushing

, , felix.schindler@wwu.de

slide-22
SLIDE 22

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 14 /21

Rewriting history

changing several commits

Live Demo

, , felix.schindler@wwu.de

slide-23
SLIDE 23

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 14 /21

Rewriting history

changing several commits

◮ git rebase -i HEAD N ◮ rewrites the last N commits

⇒ should only be used in your personal repo

, , felix.schindler@wwu.de

slide-24
SLIDE 24

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 15 /21

Rewriting history

systematical changes

Live Demo

, , felix.schindler@wwu.de

slide-25
SLIDE 25

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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

◮ other possibilities ◮ change tab width in all commits ◮ change name/mail of author ◮ whatever fits between ’ ...

, , felix.schindler@wwu.de

slide-26
SLIDE 26

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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

, , felix.schindler@wwu.de

slide-27
SLIDE 27

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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!

, , felix.schindler@wwu.de

slide-28
SLIDE 28

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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

, , felix.schindler@wwu.de

slide-29
SLIDE 29

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄ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

◮ may be OK for amend (within 60 seconds) ◮ not OK for rebase -i ◮ for filter-branch only with consent of all authors

, , felix.schindler@wwu.de

slide-30
SLIDE 30

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 17 /21

  • utline

Why Version Control? Working with an existing project Rewriting history

  • ther nice stuff

, , felix.schindler@wwu.de

slide-31
SLIDE 31

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 18 /21

  • ther nice stuff

find the hidden documentation

Live Demo

, , felix.schindler@wwu.de

slide-32
SLIDE 32

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 18 /21

  • ther nice stuff

find the hidden documentation

git show $(git blame header.hh -L N,N | awk ’{print $1}’)

, , felix.schindler@wwu.de

slide-33
SLIDE 33

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 19 /21

  • ther nice stuff

find problematic design

Live Demo

, , felix.schindler@wwu.de

slide-34
SLIDE 34

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 19 /21

  • ther nice stuff

find problematic design

◮ download git-churn:

https://github.com/garybernhardt/dotfiles/blob/ f0c0ff92209e5aed4fa3ef6faf056eb9944a8f12/bin/git-churn

◮ git churn --since=’6 months ago’ path/ | tail

, , felix.schindler@wwu.de

slide-35
SLIDE 35

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 20 /21

resources

◮ http://git-scm.com/book ◮ https://try.github.io ◮ http://mislav.uniqpath.com ◮ http://www.google.com

, , felix.schindler@wwu.de

slide-36
SLIDE 36

living knowledge WWU Münster

WESTFÄLISCHE WILHELMS-UNIVERSITÄT MÜNSTER

Version Control with git 21 /21

Thank you for your attention!

, , felix.schindler@wwu.de