Slide 1

Slide 1 text

Learning Git with Workflows Mosky

Slide 2

Slide 2 text

This slides 2

Slide 3

Slide 3 text

This slides won't explain every options of Git commands; and the internal of Git. 2

Slide 4

Slide 4 text

This slides won't explain every options of Git commands; and the internal of Git. will let you start to use Git immediately; and learn the common Git workflows. 2

Slide 5

Slide 5 text

Mosky 3

Slide 6

Slide 6 text

Mosky A Python engineer at Pinkoi 3

Slide 7

Slide 7 text

Mosky A Python engineer at Pinkoi An author of some Python packages MoSQL, Clime, ... 3

Slide 8

Slide 8 text

Mosky A Python engineer at Pinkoi An author of some Python packages MoSQL, Clime, ... A speaker at several conferences PyCon APAC 2013, COSCUP 2013, PyCon TW 2013, ... 3

Slide 9

Slide 9 text

Mosky A Python engineer at Pinkoi An author of some Python packages MoSQL, Clime, ... A speaker at several conferences PyCon APAC 2013, COSCUP 2013, PyCon TW 2013, ... A Python trainer 3

Slide 10

Slide 10 text

Mosky A Python engineer at Pinkoi An author of some Python packages MoSQL, Clime, ... A speaker at several conferences PyCon APAC 2013, COSCUP 2013, PyCon TW 2013, ... A Python trainer http://mosky.tw/ 3

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Outline 6

Slide 15

Slide 15 text

Outline Setup Git 6

Slide 16

Slide 16 text

Outline Setup Git Routine Core Secondary 6

Slide 17

Slide 17 text

Outline Setup Git Routine Core Secondary Branching 6

Slide 18

Slide 18 text

Outline Setup Git Routine Core Secondary Branching Remote Repository 6

Slide 19

Slide 19 text

Outline Setup Git Routine Core Secondary Branching Remote Repository A Co-working Workflow 6

Slide 20

Slide 20 text

Setup Git

Slide 21

Slide 21 text

Get Git! 8

Slide 22

Slide 22 text

Get Git! Ubuntu, Debian or any APT-based Linux $ sudo apt-get install git-core 8

Slide 23

Slide 23 text

Get Git! Ubuntu, Debian or any APT-based Linux $ sudo apt-get install git-core Mac $ brew install git http://brew.sh/ 8

Slide 24

Slide 24 text

Get Git! Ubuntu, Debian or any APT-based Linux $ sudo apt-get install git-core Mac $ brew install git http://brew.sh/ Windows http://git-scm.com/download/win 8

Slide 25

Slide 25 text

Is Git there? 9

Slide 26

Slide 26 text

GUIs are available 10

Slide 27

Slide 27 text

GUIs are available Thanks GitHub! 10

Slide 28

Slide 28 text

GUIs are available Thanks GitHub! "Github for Mac" http://mac.github.com/ 10

Slide 29

Slide 29 text

GUIs are available Thanks GitHub! "Github for Mac" http://mac.github.com/ "Github for Windows" http://windows.github.com/ 10

Slide 30

Slide 30 text

GUIs are available Thanks GitHub! "Github for Mac" http://mac.github.com/ "Github for Windows" http://windows.github.com/ Other http://git-scm.com/downloads/guis 10

Slide 31

Slide 31 text

Tell Git who you are 11

Slide 32

Slide 32 text

Tell Git who you are $ git config --global user.name "Mosky Liu" 11

Slide 33

Slide 33 text

Tell Git who you are $ git config --global user.name "Mosky Liu" $ git config --global user.email [email protected] 11

Slide 34

Slide 34 text

Other Git configs 12

Slide 35

Slide 35 text

Other Git configs $ git config --global core.editor emacs 12

Slide 36

Slide 36 text

Other Git configs $ git config --global core.editor emacs $ git config --global merge.tool vimdiff 12

Slide 37

Slide 37 text

Other Git configs $ git config --global core.editor emacs $ git config --global merge.tool vimdiff $ git config --list 12

Slide 38

Slide 38 text

Other Git configs $ git config --global core.editor emacs $ git config --global merge.tool vimdiff $ git config --list $ vim ~/.gitconfig 12

Slide 39

Slide 39 text

Other Git configs $ git config --global core.editor emacs $ git config --global merge.tool vimdiff $ git config --list $ vim ~/.gitconfig http://j.mp/mosky-gitconfig 12

Slide 40

Slide 40 text

Core Routine

Slide 41

Slide 41 text

Create a repository 14

Slide 42

Slide 42 text

Create a repository $ git init [] 14

Slide 43

Slide 43 text

Commit changes 15

Slide 44

Slide 44 text

Commit changes $ git add ... 15

Slide 45

Slide 45 text

Commit changes $ git add ... $ git commit 15

Slide 46

Slide 46 text

Simplest Workflow 16

Slide 47

Slide 47 text

Simplest Workflow (1) $ git init 16

Slide 48

Slide 48 text

Simplest Workflow (1) $ git init (2) (modify file) 16

Slide 49

Slide 49 text

Simplest Workflow (1) $ git init (2) (modify file) (3) $ git add ... 16

Slide 50

Slide 50 text

Simplest Workflow (1) $ git init (2) (modify file) (3) $ git add ... (4) $ git commit 16

Slide 51

Slide 51 text

Simplest Workflow (1) $ git init (2) (modify file) (3) $ git add ... (4) $ git commit # Back 2 16

Slide 52

Slide 52 text

Simplest Workflow (1) $ git init (2) (modify file) (3) $ git add ... (4) $ git commit # Back 2 The end of the core --- it's super easy! 16

Slide 53

Slide 53 text

Secondary Routine

Slide 54

Slide 54 text

Check status of files 18

Slide 55

Slide 55 text

Check status of files $ git status 18

Slide 56

Slide 56 text

Check status of files $ git status 18

Slide 57

Slide 57 text

Check what you changed 19

Slide 58

Slide 58 text

Check what you changed $ git diff 19

Slide 59

Slide 59 text

Check what you changed $ git diff 19

Slide 60

Slide 60 text

Check commits 20

Slide 61

Slide 61 text

Check commits $ git log 20

Slide 62

Slide 62 text

Check commits $ git log 20

Slide 63

Slide 63 text

Move between commits 21

Slide 64

Slide 64 text

Move between commits $ git checkout 21

Slide 65

Slide 65 text

Move between commits $ git checkout 599d439fd3813298da16f12ed40f3a0 716872c30 599d439 HEAD 21

Slide 66

Slide 66 text

Name commit 22

Slide 67

Slide 67 text

Name commit $ git tag $ git checkout 599d439 $ git tag v0.1 $ git checkout v0.1 22

Slide 68

Slide 68 text

Reset to a commit 23

Slide 69

Slide 69 text

Reset to a commit $ git reset Reset HEAD to . 23

Slide 70

Slide 70 text

Make a "reverse" commit 24

Slide 71

Slide 71 text

Make a "reverse" commit $ git revert Apply a "reverse" commit. 24

Slide 72

Slide 72 text

Reset to a commit 25

Slide 73

Slide 73 text

Reset to a commit 26

Slide 74

Slide 74 text

Make a "reverse" commit 27

Slide 75

Slide 75 text

Make a "reverse" commit 28

Slide 76

Slide 76 text

Branching

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

master

Slide 86

Slide 86 text

master topic

Slide 87

Slide 87 text

master topic HEAD

Slide 88

Slide 88 text

master topic HEAD

Slide 89

Slide 89 text

master topic HEAD

Slide 90

Slide 90 text

master topic HEAD

Slide 91

Slide 91 text

master topic HEAD

Slide 92

Slide 92 text

Create a branch 32

Slide 93

Slide 93 text

Create a branch $ git branch 32

Slide 94

Slide 94 text

Create a branch $ git branch $ git checkout 32

Slide 95

Slide 95 text

Create a branch $ git branch $ git checkout or 32

Slide 96

Slide 96 text

Create a branch $ git branch $ git checkout or $ git checkout -b 32

Slide 97

Slide 97 text

Delete and list branch(es) 33

Slide 98

Slide 98 text

Delete and list branch(es) $ git branch -d Delete branch. 33

Slide 99

Slide 99 text

Delete and list branch(es) $ git branch -d Delete branch. $ git branch List branches. 33

Slide 100

Slide 100 text

Move between branches 34

Slide 101

Slide 101 text

Move between branches $ git checkout 34

Slide 102

Slide 102 text

Merge a branch back 35

Slide 103

Slide 103 text

Merge a branch back $ git checkout 35

Slide 104

Slide 104 text

Merge a branch back $ git checkout $ git merge 35

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

Branching Workflow 37

Slide 107

Slide 107 text

Branching Workflow ... 37

Slide 108

Slide 108 text

Branching Workflow ... (1) $ git branch 37

Slide 109

Slide 109 text

Branching Workflow ... (1) $ git branch (2) $ git checkout 37

Slide 110

Slide 110 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) 37

Slide 111

Slide 111 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) ... 37

Slide 112

Slide 112 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) ... (4) $ git commit 37

Slide 113

Slide 113 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) ... (4) $ git commit # Back 3 until finish "topic" 37

Slide 114

Slide 114 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) ... (4) $ git commit # Back 3 until finish "topic" (5) $ git checkout 37

Slide 115

Slide 115 text

Branching Workflow ... (1) $ git branch (2) $ git checkout (3) (modify file) ... (4) $ git commit # Back 3 until finish "topic" (5) $ git checkout (6) $ git merge 37

Slide 116

Slide 116 text

Remote Repository

Slide 117

Slide 117 text

Clone a remote repository 39

Slide 118

Slide 118 text

Clone a remote repository $ git clone 39

Slide 119

Slide 119 text

Clone a remote repository $ git clone https:// github.com/torvalds/linux.git 39

Slide 120

Slide 120 text

Create a remote repository 40

Slide 121

Slide 121 text

Create a remote repository $ git init --bare 40

Slide 122

Slide 122 text

Create a remote repository $ git init --bare or 40

Slide 123

Slide 123 text

Create a remote repository $ git init --bare or https://github.com/repositories/new 40

Slide 124

Slide 124 text

Add, remove and list remotes 41

Slide 125

Slide 125 text

Add, remove and list remotes $ git remote add can be a local path. 41

Slide 126

Slide 126 text

Add, remove and list remotes $ git remote add can be a local path. $ git remote remove 41

Slide 127

Slide 127 text

Add, remove and list remotes $ git remote add can be a local path. $ git remote remove $ git remote 41

Slide 128

Slide 128 text

Push commits to remote 42

Slide 129

Slide 129 text

Push commits to remote $ git push ... 42

Slide 130

Slide 130 text

Push commits to remote $ git push ... usually is branch or tag name [+][:] : to delete remote reference. 42

Slide 131

Slide 131 text

Pull commits from remote 43

Slide 132

Slide 132 text

Pull commits from remote $ git pull ... 43

Slide 133

Slide 133 text

A Co-working Workflow

Slide 134

Slide 134 text

Three Principles 45

Slide 135

Slide 135 text

Three Principles 1. master is production. 45

Slide 136

Slide 136 text

Three Principles 1. master is production. 2. dev only includes stable and reviewed code. 45

Slide 137

Slide 137 text

Three Principles 1. master is production. 2. dev only includes stable and reviewed code. 3. Create topic branch to resolve issue all the time. 45

Slide 138

Slide 138 text

Three Phases 46

Slide 139

Slide 139 text

Three Phases 1. Resolving Create a topic branch to resolve issue. 46

Slide 140

Slide 140 text

Three Phases 1. Resolving Create a topic branch to resolve issue. 2. Reviewing Review the code. 46

Slide 141

Slide 141 text

Three Phases 1. Resolving Create a topic branch to resolve issue. 2. Reviewing Review the code. 3. Cleanup Merge into dev and remove topic branch. 46

Slide 142

Slide 142 text

47

Slide 143

Slide 143 text

Assigner: "We need to resolve this issue." 47

Slide 144

Slide 144 text

Assigner: "We need to resolve this issue." Assignee: "Yes, sir!" 47

Slide 145

Slide 145 text

Assigner: "We need to resolve this issue." Assignee: "Yes, sir!" Assignee (dev) $ git checkout -b topic 47

Slide 146

Slide 146 text

Assigner: "We need to resolve this issue." Assignee: "Yes, sir!" Assignee (dev) $ git checkout -b topic Assignee (topic) $ (commit...) 47

Slide 147

Slide 147 text

Assigner: "We need to resolve this issue." Assignee: "Yes, sir!" Assignee (dev) $ git checkout -b topic Assignee (topic) $ (commit...) Assignee (topic) $ git push origin topic 47

Slide 148

Slide 148 text

Assigner: "We need to resolve this issue." Assignee: "Yes, sir!" Assignee (dev) $ git checkout -b topic Assignee (topic) $ (commit...) Assignee (topic) $ git push origin topic Until resolve, call assigner for review. 47

Slide 149

Slide 149 text

48

Slide 150

Slide 150 text

Assignee: "I resolved!" 48

Slide 151

Slide 151 text

Assignee: "I resolved!" Assigner: "Let me review." 48

Slide 152

Slide 152 text

Assignee: "I resolved!" Assigner: "Let me review." Assigner (dev) $ git checkout -b topic 48

Slide 153

Slide 153 text

Assignee: "I resolved!" Assigner: "Let me review." Assigner (dev) $ git checkout -b topic Assigner (topic) $ git pull origin topic 48

Slide 154

Slide 154 text

Assignee: "I resolved!" Assigner: "Let me review." Assigner (dev) $ git checkout -b topic Assigner (topic) $ git pull origin topic Assigner (topic) $ git diff ...dev 48

Slide 155

Slide 155 text

Assignee: "I resolved!" Assigner: "Let me review." Assigner (dev) $ git checkout -b topic Assigner (topic) $ git pull origin topic Assigner (topic) $ git diff ...dev If it is not good enough, call assignee to fix. 48

Slide 156

Slide 156 text

49

Slide 157

Slide 157 text

Assigner (topic) $ git checkout dev 49

Slide 158

Slide 158 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic 49

Slide 159

Slide 159 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic Assigner (dev) $ git push origin dev 49

Slide 160

Slide 160 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic Assigner (dev) $ git push origin dev Assigner: "Good job!" 49

Slide 161

Slide 161 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic Assigner (dev) $ git push origin dev Assigner: "Good job!" Assignee (dev) $ git branch -d topic 49

Slide 162

Slide 162 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic Assigner (dev) $ git push origin dev Assigner: "Good job!" Assignee (dev) $ git branch -d topic Assignee (dev) $ git push origin :topic 49

Slide 163

Slide 163 text

Assigner (topic) $ git checkout dev Assigner (dev) $ git merge topic Assigner (dev) $ git push origin dev Assigner: "Good job!" Assignee (dev) $ git branch -d topic Assignee (dev) $ git push origin :topic Assignee (dev) $ git pull origin dev 49

Slide 164

Slide 164 text

No content

Slide 165

Slide 165 text

End

Slide 166

Slide 166 text

End 52

Slide 167

Slide 167 text

End Use branch! 52

Slide 168

Slide 168 text

End Use branch! Workflow does matter. 52

Slide 169

Slide 169 text

End Use branch! Workflow does matter. Git still has many magics. 52

Slide 170

Slide 170 text

End Use branch! Workflow does matter. Git still has many magics. Tips: http://j.mp/mosky-gitconfig 52

Slide 171

Slide 171 text

End Use branch! Workflow does matter. Git still has many magics. Tips: http://j.mp/mosky-gitconfig Q&A 52