PowerPoint-Präsentation · 2020. 1. 22. · Example 1 fast-forward Merge •create code for actual...

Post on 27-Feb-2021

1 views 0 download

transcript

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()

2 3 4 5

dev master

HEAD

23

We created the “dev“ branch.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()

2 3 4 5

dev master

HEAD

24

We checked-out the “dev“ branch.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()

2 3 4 5

dev master

HEAD

game.py .gitignore

25

We created the code for the actual game and the “.gitignore” file.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()

2 3 4 5

dev master

HEAD

game.py .gitignore

26

We staged both files.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

2 3 4 5

dev

HEAD

6

master

27

We created a commit.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

2 3 4 5

dev

HEAD

6

master

28

We checked-out the “master“ branch.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

2 3 4 5

devmaster

HEAD

6

29

We merged “dev“ into “master”.

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

2 3 4 5

master

HEAD

6

all_the_same 48

We created the “all_the_same“ branch.

Working Directory

Staging Area

Repository

1

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

2 3 4 5

master

HEAD

6

all_the_same 49

We checked-out the “all_the_same“ branch.

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()

1 2 3 4 5 6

7all_the_same

master

HEAD 50

We created a new commit.

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()

1 2 3 4 5 6

7all_the_same

master

HEAD

51

We checked-out the “ master“ branch.

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw

master

HEAD

1 2 3 4 5 6 8

7all_the_same 52

We created a new commit.

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

master

HEAD

1 2 3 4 5 6 8

7all_the_same

9

53

We merged “all_the_same” into “master”.

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

master

HEAD

1 2 3 4 5 6 8

7

9

54

We deleted the “all_the_same” branch.

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

Code before paths diverged:

Changes on the “master” branch:

Changes on the “valid_move” branch:

71

72

73

74

75

76

77

Working Directory

Staging Area

Repository

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

master

HEAD1 2 3 4 5 6 8

7

9

valid_move 78

We created and checked-out the “valid_move” branch.

10

Working Directory

Staging Area

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

10 – add check if player‘s move is valid

valid_move

Repository

1 2 3 4 5 6 8

7

9

master

HEAD

79

We created a new commit.

10

Working Directory

Staging Area

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

10 – add check if player‘s move is valid

valid_move

Repository

1 2 3 4 5 6 8

7

9

master

HEAD

80

We checked-out the “master” branch.

10

Working Directory

Staging Area

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

10 – add check if player‘s move is valid11 – rename change() to make_move()

valid_move

Repository

1 2 3 4 5 6 8

7

9

master

HEAD

11

81

We created a new commit.

10

Working Directory

Staging Area

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

10 – add check if player‘s move is valid11 – rename change() to make_move()12 – merge branch ‘valid_move‘

valid_move

Repository

1 2 3 4 5 6 8

7

9 11 12

master

HEAD

82

We merged “valid_move” into “master”.

10

Working Directory

Staging Area

11 – initial commit12 – update README13 – define change()14 – enable variable size of the game board15 – define determine_game_status()16 – create code for the actual game

17 – refactor code into all_the_same()18 – add check for a draw19 – merge branch ‘all_the_same‘

10 – add check if player‘s move is valid11 – rename change() to make_move()12 – merge branch ‘valid_move‘

Repository

1 2 3 4 5 6 8

7

9 11 12

master

HEAD

83

We deleted the “valid_move” branch.

Merge Type Commits

Example 1 fast-forward Merge • create code for actual game

Example 2three-way merge without

Merge-Conflict• refactor code into all_the_same()• add check for a draw

Example 3three-way merge with

Merge-Conflict• add check if player‘s move is valid• rename change() to make_move()

Examples for Merging Branches

84

Version Control

Creating a Commit BranchesWorking Directory

Staging Area

Local Repository

git branch

git merge

git status

git add

git commit

git restore

git log

git checkout

git diff

git clone

git init

git config

85