-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-presentation.html
More file actions
165 lines (140 loc) · 6.65 KB
/
git-presentation.html
File metadata and controls
165 lines (140 loc) · 6.65 KB
1
2
3
4
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html>
<head>
<title>Quick-and-dirty Intro to Git</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Quick-and-dirty Intro to Git
## (by someone who doesn't know that much about it either) ##
Babak Esfandiari
babak@sce.carleton.ca
---
# What is Git?
- A distributed version control system
- local repositories (so, not client-server), means can work offline
- teamwork achieved through multiple repositories and agreed upon workflow (more on that later)
- created by Linus Torvalds to solve his own problems
---
# Installing Git
http://git-scm.com/
- comes with GUI tools
- but on Mac or Linux, can just use the terminal
- on Windows, can use the Powershell, or use Git Bash that comes with Git Gui
- once installed, some configuration required
- see http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup
---
# `git init`
- creates a local repository (or just a "repo" if you're a cool kid) in current folder
- alternately, if you don't want to start from scratch, you can clone an existing repo: `git clone <repo url>`
---
# `git status`
- is your best friend!
- tells you if you have any files that you have changed
- use it often to figure out where you are
- try it now!
---
# `vi hello-world.txt`
- create a file you want to work on, using your favorite editor
- what does `git status` say now?

---
# `git commit`
- *commits* your changes, i.e. create a new version/snapshot in the repo using all the staged files.
- try it. What happens?
---
# `git add hello-world.txt`
- Oops! You needed to *stage* your changes to commit first
- type the above command
- now what does the fo.. I mean `git status` say?
- `git add .` adds everything at once
---
# `git commit`
- now we're getting somewhere!
- you are asked to enter a commit message. Keep it short but informative. You'll use these messages later to know what each snapshot was all about.
- `git commit -m "message"` includes the message directly and skips the prompting part
- `git commit -a` skips the staging part (at least for the files that you have added at least once previously)
---
# `git log`
- tells you the history in your current branch (more on branches later)
- notice how each commit is identified by a hash. You can use this hash (or I believe the first few digits thereof) to refer to a given snapshot, and to check it out later.
- your other BFF! Use it often.

---
#`git diff`
- compares what is unstaged in your working directory with what is staged, i.e. ready to go into the next commit
- `git diff --staged` compares what is staged with what is in the last commit
- or just use the git gui for more intuitive output
---
#Branches
- a branch in Git is really just a pointer to a given snapshot
- use it to for exploratory purposes
- `git branch` lists the branches you currently have
- `git branch mybranch` create a new branch called "mybranch"
- `git checkout mybranch` switches to that branch
- from now on any new commits you make will be made down that branch you switched to
- exercise: commit a new snapshot here, and jump back to the master branch
- great example here: http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is
---
#`git merge mybranch`
- allows you to move the pointer of your current branch to the snapshot located by the pointer of "otherbranch"
- depending on the configuration of your tree of snapshots, this can be:
- just a straightforward pointer move
- needing the creation of a new snapshot that inherits from the two branches
- needing some conflict resolution
- gory details here: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
---
#Collaborative work: pushing and pulling branches
- you can work with others by synchronizing your repo with the repo you cloned from
- the repo you cloned from is known as the "origin"
- there's more to this, but... to merge changes that happened on the remote master branch to your current local branch, use `git pull`
- to push your changes to the remote branch (assuming you have access rights!), use `git push'
- gory details here: http://git-scm.com/book/en/Git-Branching-Remote-Branches
---
#GitHub
- A host for your open source projects (for free!), and much more:
- as the name indicates, hosts a repo for you on their site
- issue tracking
- easy code review ("tag" people using their GitHub handle to make them aware of something in need of review)
- hooks for running third party tools (e.g., CI)
---
#Typical GitHub Workflow
1. create a repo on GitHub
2. clone it to a local repo
3. push local changes to origin
4. if others like what they see, they can create a fork (their own independent clone of your repo)
5. you don't want random people to have push access to your GitHub repo, so if they want to offer you some patch they made, they'll create a "pull request" (a.k.a a "PR" if you're a cool cat)
- at this point, some back-and-forth discussion and code review can happen, until you are satisfied with the changes, at which point you can merge their PR into your own GitHub repo. Open source collaboration in action!
---
#GitHub for Edu
- Usually private repos aren't free, but GitHub gives you a certain number for free if you are from a University
- it can be handy for assignments or group projects, as giving feedback is much nicer
- for group projects, it's a bit of work creating the repos and allocating students
- first year using it, so will know more by term end!
---
# Resources
- Pro Git is a free book [available](http://git-scm.com/book) at the Git web site.
---
# Overtime!
[http://www.nmai.ca/research-projects/socialwiki](http://www.nmai.ca/research-projects/socialwiki "Social Wiki")
</textarea>
<script src="http://gnab.github.io/remark/downloads/remark-latest.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create();
</script>
</body>
</html>