04-git-demo.adoc 2.06 KB
Newer Older
1
2
3
= SCM - Git demo
:customcss: slides.css
:icons: font
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
4
:includedir: includes/
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
:LECTURE_TOPIC: Git demo
:LECTURE_NO: 4th lecture

include::{includedir}header.adoc[]


[.smaller-80][.center-paragraph]
IT1901 Fall 2020 - {LECTURE_NO}

[background-color = "#124990"]
[color = "#fff6d5"]
== Git demo

== Installing and setting up git

- Go to https://git-scm.com/downloads
- Download and install the right version for your OS
- git commands are now available

[.grid-left-right-50-50]
== Typical sequence (share project) 

[.area-left]
- starting a project and sharing it on Gitlab for team collaboration
** `git init`
** `git status`

[.area-right]
** `git add ...`
** `git commit ...`
** `git remote ...`
** `git push`

== Commit messages

image::../images/git_commit_2x.png[size=75%]
[.smaller-40]
https://xkcd.com/1296/

== Commit messages (seriously)

- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how



[.grid-left-right-50-50]
== Typical sequence (simple collaboration)

[.area-left]
- working with a shared project
** `git clone`
** `git pull`

[.area-right]
** `git status` 
** `git add ...`
** `git commit ...`
** `git push`

== Conflicts (1)

** when same files (lines) are changed by different devs
** automatic merge is not possible 
** we need to solve that to be able to push our changes 

== Conflicts (2) - Setup

- `git config merge.tool vimdiff`
- `git config merge.conflictstyle diff3`
- `git config mergetool.prompt false`

== Conflicts (3) - Solving

- `git mergetool`
- `:wqa` save and exit from vi
- `git commit -m "message"`
- `git clean` remove file (might remove other untracked files)


== Typical sequence (with branching)

- working with branches
** `git pull` 
** `git checkout -b <branch_name>` 
** `git status` + `git add ...` + `git commit ...` 
** `git checkout master` 
** `git merge <branch_name>` 


include::{includedir}footer.adoc[]