-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path02-setup.html
150 lines (150 loc) · 8.14 KB
/
02-setup.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>ARC Training: Version Control with Git</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://arcleeds.github.io/git-workshop/" title="Advanced Research Computing">
<img alt="ARC banner" src="img/arc-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">Version Control with Git</h1></a>
<h2 class="subtitle">Setting Up Git</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
<li>Configure <code>git</code> the first time is used on a computer.</li>
<li>Understand the meaning of the <code>--global</code> configuration flag.</li>
</ul>
</div>
</section>
<p>When we use Git on a new computer for the first time, we need to configure a few things. Below are a few examples of configurations we will set as we get started with Git:</p>
<ul>
<li>our name and email address,</li>
<li>to colourise the output,</li>
<li>what our preferred text editor is,</li>
<li>and that we want to use these settings globally (i.e. for every project)</li>
</ul>
<p>On a command line, Git commands are written as <code>git verb</code>, where <code>verb</code> is what we actually want to do. So here is how Dracula sets up his new laptop:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">git</span> config --global user.name <span class="st">"Vlad Dracula"</span>
$ <span class="kw">git</span> config --global user.email <span class="st">"vlad@tran.sylvan.ia"</span>
$ <span class="kw">git</span> config --global color.ui <span class="st">"auto"</span></code></pre></div>
<p>(Please use your own name and email address instead of Dracula’s.)</p>
<p>He also has to set his favorite text editor, following this table:</p>
<table>
<thead>
<tr class="header">
<th align="left">Editor</th>
<th align="left">Configuration command</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">nano</td>
<td align="left"><code>$ git config --global core.editor "nano -w"</code></td>
</tr>
<tr class="even">
<td align="left">Text Wrangler</td>
<td align="left"><code>$ git config --global core.editor "edit -w"</code></td>
</tr>
<tr class="odd">
<td align="left">Sublime Text (Mac)</td>
<td align="left"><code>$ git config --global core.editor "subl -n -w"</code></td>
</tr>
<tr class="even">
<td align="left">Sublime Text (Win, 32-bit install)</td>
<td align="left"><code>$ git config --global core.editor "'c:/program files (x86)/sublime text 3/sublime_text.exe' -w"</code></td>
</tr>
<tr class="odd">
<td align="left">Sublime Text (Win, 64-bit install)</td>
<td align="left"><code>$ git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w"</code></td>
</tr>
<tr class="even">
<td align="left">Notepad++ (Win)</td>
<td align="left"><code>$ git config --global core.editor "'c:/program files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"</code></td>
</tr>
<tr class="odd">
<td align="left">Kate (Linux)</td>
<td align="left"><code>$ git config --global core.editor "kate"</code></td>
</tr>
<tr class="even">
<td align="left">Gedit (Linux)</td>
<td align="left"><code>$ git config --global core.editor "gedit -s -w"</code></td>
</tr>
<tr class="odd">
<td align="left">emacs</td>
<td align="left"><code>$ git config --global core.editor "emacs"</code></td>
</tr>
<tr class="even">
<td align="left">vim</td>
<td align="left"><code>$ git config --global core.editor "vim"</code></td>
</tr>
</tbody>
</table>
<p>The four commands we just ran above only need to be run once: the flag <code>--global</code> tells Git to use the settings for every project, in your user account, on this computer.</p>
<p>You can check your settings at any time:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">git</span> config --list</code></pre></div>
<p>You can change your configuration as many times as you want: just use the same commands to choose another editor or update your email address.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2 id="proxy"><span class="glyphicon glyphicon-pushpin"></span>Proxy</h2>
</div>
<div class="panel-body">
<p>In some networks you need to use a <a href="https://en.wikipedia.org/wiki/Proxy_server">proxy</a>. If this is the case, you may also need to tell Git about the proxy:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">git</span> config --global http.proxy proxy-url
$ <span class="kw">git</span> config --global https.proxy proxy-url</code></pre></div>
<p>To disable the proxy, use</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">git</span> config --global --unset http.proxy
$ <span class="kw">git</span> config --global --unset https.proxy</code></pre></div>
</div>
</aside>
<p>Not all Windows computers will have a command line editor installed, so:</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2 id="installing-nano-editor-on-windows"><span class="glyphicon glyphicon-pushpin"></span>Installing nano editor on Windows</h2>
</div>
<div class="panel-body">
<p>If your Windows PC doesn’t have the nano editor installed, you can install it through the <a href="https://chocolatey.org/">Chocolatey</a> package manager.</p>
<p>First install Chocolatey. In a Windows command shell enter the following all on one line:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">C</span>:<span class="dt">\></span> @powershell -NoProfile -ExecutionPolicy unrestricted -Command <span class="st">"(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) ></span><span class="ot">$null</span><span class="st"> 2>&1"</span> <span class="kw">&&</span> <span class="kw">SET</span> PATH=%PATH%<span class="kw">;%ALLUSERSPROFILE%</span>\chocolatey\bin</code></pre></div>
<p>Then install nano:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">C</span>:<span class="dt">\></span> choco install nano</code></pre></div>
</div>
</aside>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/git-novice">Source</a>
<a class="label swc-blue-bg" href="mailto:arc-help@lists.leeds.ac.uk">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</body>
</html>