forked from sdslabs/git-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
208 lines (201 loc) · 9.65 KB
/
index.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<title></title>
<style>
* {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}
body {
max-width: 50em;
margin: 0 auto;
color: #111;
}
pre, code {
font-family: Monaco, Courier New, monospace;
font-size: 11px;
}
h1 {
font-size: 45px;
font-weight: 100;
letter-spacing: -1px;
margin-bottom: -5px;
}
h1 code {
font-size: 40px;
}
h2 {
color: rgb(43,105,145);
font-weight: bold;
margin-bottom: -5px;
}
h2 code {
font-size: 22px;
}
h3 {
margin-bottom: -5px;
}
h3 code {
font-size: 16px;
}
a {
color: blue;
text-decoration: none;
}
a:visited {
color: navy;
}
a:hover {
text-decoration: underline;
}
pre {
border-width: 1px;
border-color: #777;
border-style: solid;
padding: 0.5em;
background-color: #111;
overflow: auto;
color: #CCC;
}
p, li {
font-size: 13px;
line-height: 18px;
}
</style>
</head>
<body>
<h1 id="git-lecture-notes">Git Lecture Notes</h1>
<h2 id="topics-discussed">Topics Discussed</h2>
<ul>
<li>SSH, public key authentication.</li>
<li>Version Control</li>
<li>Git Basics</li>
<li>Git Workflow</li>
<li>Github</li>
<li>Extra git commands</li>
<li>Git GUI's</li>
</ul>
<h2 id="ssh">SSH</h2>
<h3 id="installing-ssh">Installing ssh</h3>
<p><code>sudo apt-get install openssh</code></p>
<h3 id="connecting-to-server">Connecting to server</h3>
<p><code>$ ssh username@hostname</code></p>
<h3 id="public-key-authentication">Public key authentication</h3>
<p><code>ssh-keygen -t rsa</code> The private key is at <code>~/.ssh/id_rsa</code> while the public key is at <code>~/.ssh/id_rsa.pub</code> The server needs your public key to authenticate the connection.</p>
<h2 id="version-control">Version Control</h2>
<ul>
<li>central VCS v/s Distributed VCS</li>
<li>Why Version Control</li>
<li>Helps remember history of project</li>
<li>Move back and forth in history</li>
<li>Any break in code can be fixed easily</li>
<li>Any bugs introduced can be traced back to the code that made it</li>
<li>Examples : svn, cvs, mercurial, bzr, etc</li>
</ul>
<h2 id="git-basics">Git Basics</h2>
<p>This is just a simple walkthrough. You are encouraged to try out these steps on your own.</p>
<ul>
<li><code>git init</code> creates a new repository</li>
<li><code>git clone <url> [folder]</code>clones a repo from the server</li>
<li><code>git add <filename></code> adds files to index</li>
<li><code>git add .</code> adds everything to index</li>
<li><code>git commit</code> creates a commit</li>
<li><code>git commit -a</code> adds all <em>modified</em> files to the index and starts a commit</li>
<li>A blank commit message aborts the commit</li>
<li><code>git checkout <ref></code> changes your working directory to a commit/tag/branch</li>
<li><code>git checkout -b branchname</code> creates a new branch and shifts to it</li>
<li><code>git branch</code> shows a list of all branches & the current branch</li>
<li><code>git branch <branch></code> creates a new branch, but does not switch to it</li>
<li><code>git merge branchname</code> merges the branch with the current branch</li>
<li><code>git tag</code> marks a tag for the current commit</li>
</ul>
<h3 id="a-little-more">A Little More</h3>
<ul>
<li><code>git pull [remote] [ref]</code> fetches and merges the branch/commit with the current HEAD</li>
<li><code>git fetch [remote] [ref]</code> fetches the commits for merging</li>
<li>Therefore, <code>pull</code> = <code>fetch</code> + <code>merge</code></li>
<li>Similarly, <code>checkout -b</code> = <code>branch</code> + <code>checkout</code> //Create and checkout</li>
</ul>
<h2 id="little-of-git-jargon">Little of git-jargon</h2>
<p>Read more over <a href="http://book.git-scm.com/7_glossary.html">here</a></p>
<ul>
<li><code>branch</code> is an active line of development.</li>
<li><code>commit</code> is a snapshot of the working directory</li>
<li><code>tag</code> is an alias of a particular commit</li>
<li><code>HEAD</code> is a pointer to the current checked out branch</li>
<li><code>tree</code> is the internal representation of working directory in git</li>
<li><code>blob</code> is the internal representation of files in git</li>
<li><code>index</code> is a staging area for the commit in progress</li>
</ul>
<h2 id="git-workflow">Git Workflow</h2>
<h3 id="fork-merge-pull">Fork, Merge, Pull</h3>
<p>This is what Github follows. People create their own fork version of the repo, and send back pull requests</p>
<h3 id="shared-repository">Shared Repository</h3>
<p>A single repository shared among various people can be used successfully if the project is closed, and has known developers This is mainly for <a href="github.com/sdslabs">organizations</a></p>
<h3 id="branching-model">Branching Model</h3>
<p>Mainly from <a href="http://nvie.com/posts/a-successful-git-branching-model/">here</a><br />Topics include branches, stable, hotfix, release, development, feature branch etc.</p>
<h2 id="github">Github</h2>
<ul>
<li><a href="http://github.com"><code class="url">http://github.com</code></a> is an awesome site that allows people to share code, projects and collaborate easily using git.</li>
<li>Create an account</li>
<li>Setting up ssh-keys</li>
<li>Creating repository</li>
<li>Setting <code>remotes</code></li>
<li><code>push</code>, <code>pull</code>, <code>fetch</code>, <code>merge</code></li>
<li><a href="https://github.com/defunkt/github-gem">Github gem</a></li>
<li>Online Editing as well (press <code>e</code> on a file)</li>
</ul>
<h2 id="some-other-things">Some other things</h2>
<ul>
<li><code>git log</code> allows you to see your history</li>
<li><code>git log --oneline</code> gives single line history</li>
<li><code>git log --pretty</code> gives better output</li>
<li><code>git log --graph</code> shows your commit graph</li>
<li>Git GUI Systems - <code>gitg</code>, <code>git-cola</code>, <code>qgit</code>, <code>giggle</code> and the windows git-gui as well.</li>
<li><code>.gitignore</code> file to store system specific stuff (configuration, databases, temp files, cache, build)</li>
</ul>
<h2 id="redmine">Redmine</h2>
<ul>
<li>Create user accounts (Registration)</li>
<li><code>git config user.name</code> and <code>git config user.email</code> should be setup</li>
<li>Pass along the public keys (via email)</li>
</ul>
<h2 id="commit-messages-editing">Commit Messages Editing</h2>
<p>When you make commits on git, it uses your default text editors to type the commit message. This is set to <code>vim</code> in Windows and Linux. Linux folks can change it to anything else by setting the $EDITOR variable by the following command: <code>export EDITOR=nano</code> (Replace nano with the editor of your choice like gedit geany etc)</p>
<p>You can also save the setting in your git global configuration, by : <code>git config --global core.editor "nano"</code></p>
<p>As per <a href="http://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows">this question on SO</a>, you can use Notepad++, or notepad etc on git on Windows as well.</p>
<p><code>git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"</code></p>
<p>Take care about the slashes, and the path to your editor of choice. Don't use notepad, it screws with the newlines.</p>
<h3 id="vim">Vim</h3>
<p>If you're stuck with vim for some reason, do the following in the commit window</p>
<ol style="list-style-type: decimal">
<li>Press <code>i</code> to go to insert mode</li>
<li>Type your commit message</li>
<li>Press <code>Esc</code></li>
<li>Type <code>:wq</code>. The colon is important</li>
<li>Press <code>Enter</code></li>
<li>That's it, your commit should be successful</li>
</ol>
<p>Remember, an empty commit message aborts the commit. Also the best way to commit easily is:</p>
<p><code>git commit -m "Commit Message Here"</code> to just type the commit message on the command line, and leave out all the hassle of the editor</p>
<h1 id="resources-on-git">Resources on Git</h1>
<ul>
<li><a href="http://help.github.com/git-cheat-sheets/">Git Cheat Sheets & Excellent starting guide</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/everyday.html">Everyday GIT With 20 Commands Or So</a></li>
<li><a href="http://progit.org/book/">Pro Git Book</a></li>
<li><a href="http://gitref.org/">Git Reference</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html">Git Tutorial</a></li>
<li><a href="http://book.git-scm.com/">Git Community Book</a></li>
<li><a href="http://www.ralfebert.de/tutorials/git/">Another git tutorial</a></li>
<li><a href="http://sixrevisions.com/resources/git-tutorials-beginners/">Git beginner tutes</a></li>
<li><a href="http://eagain.net/articles/git-for-computer-scientists/">Git for Computer Scientists</a></li>
<li><a href="http://ftp.newartisans.com/pub/git.from.bottom.up.pdf">Git from bottom up</a></li>
<li><a href="http://learn.github.com/p/intro.html">Git Video Tutorials by Github</a></li>
<li><a href="http://pragprog.com/book/tsgit/pragmatic-version-control-using-git">Pragmatic Version Control using Git</a></li>
<li><a href="http://whygitisbetterthanx.com/">Why Git is Better than X</a> - Replace X with any VCS</li>
<li><a href="http://nvie.com/posts/a-successful-git-branching-model/">A successful Git branching Model</a></li>
</ul>
</body>
</html>