forked from sdslabs/git-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lecture.html
115 lines (115 loc) · 6.7 KB
/
lecture.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
<style>
*{
font-family:Arial,verdana;
margin:5px;
font-size:13px;
}
li:nth-child(even){background:#F1F1F1;}
li:nth-child(odd){background:#fff;}
</style>
<h1>Git Lecture Notes</h1>
<h2>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>SSH</h2>
<h3>Installing ssh</h3>
<p><code>sudo apt-get install openssh</code></p>
<h3>Connecting to server</h3>
<p><code>$ ssh username@hostname</code></p>
<h3>Public key authentication</h3>
<p><code>ssh-keygen -t rsa</code> The private key is at <code>~/.ssh/id_rsa</code> while the private key is at <code>~/.ssh/id_rsa.pub</code> The server needs your public key to authenticate the connection.</p>
<h2>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>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 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 <??></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 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>
<h2>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>Git workflow</h2>
<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>Github</h2>
<ul>
<li><a href="http://github.com">http://github.com</a> is an awesome site that allows people to share code, projects and colloborate 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>Github gem</li>
</ul>
<h2>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>Redmine</h2>
<ul>
<li>Create user accounts</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>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>Vim</h3>
<p>If you're stuck with vim for some reason, do the following in the commit window 1. Press <code>i</code> to go to insert mode 1. Type your commit message 1. Press <code>Esc</code> 1. Type <code>:wq</code>. The colon is important 1. Press <code>Enter</code> 1. That's it, your commit should be successful</p>
<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>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">http://learn.github.com/p/intro.html</a> - contains video tutorials on how to use git.</li>
<li>There is this book : Pragmatic Version Control , Using Git. you could download it from <library.nu></li>
</ul>