-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheclipse_setup.html
242 lines (235 loc) · 9.1 KB
/
eclipse_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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RIT CS Git Tutorial | Eclipse</title>
<link rel="shortcut icon" href="Media/CSC_logo.ico">
<link rel="stylesheet" type="text/css" href="custom.css">
</head>
<body>
<!-- header -->
<div id="topbar">
<div class="barbutton">
<img height="40" src="Media/CSC_logo.PNG"/>
</div>
<div class="barbutton">
<a href="index.html">Home</a>
</div>
<div class="barbutton">
<a href="vocab.html">Vocab</a>
</div>
<div class="barbutton">
<a href="setup.html">Setup</a>
</div>
<div class="barbutton">
<a href="committing.html">Committing</a>
</div>
<div class="barbutton">
<a href="eclipse_setup.html">Eclipse and Git</a>
</div>
<div class="barbutton">
<a href="general.html">FAQ</a>
</div>
<div class="barbutton">
<img height="40" src="Media/git.png"/>
</div>
</div>
<!-- end header -->
<h1>Configuring Git for Eclipse</h1>
<!-- ====================================================================== -->
<div>
<p>
<img border=0 width=150 src="Media/git.png"/>
</p>
<p> Many of the introductory CS courses recommend the use of Eclipse.
Luckily, Eclipse can be easily configured to work with your existing
Git repository!
</p>
<p> To access your Git repository through Eclipse, follow the following steps
<u>exactly</u>:
<ol>
<li> If you are working on a CS system, open up a terminal window.</li>
<li> If you are on your personal machine, choose the appropriate
course of action:
<ul>
<li>Linux or Mac machine:
<ol>
<li> Open the terminal window.
</li>
<li> SSH into a CS system with the following command:
<pre>$ ssh {your_username}@glados.cs.rit.edu</pre>
</li>
<li> Enter your CS password when prompted.</li>
</ol>
</li>
<li>Windows machine:
<ol>
<li> Launch <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">PuTTY</a>.</li>
<li> In the "Host Name" box, put
<code>{your_username}@glados.cs.rit.edu</code>
</li>
<li> Click "Open".</li>
<li> Enter your CS password when prompted.</li>
</ol>
</li>
</ul>
</li>
<li> Navigate to your home directory:
<pre>$ cd</pre>
</li>
<li> Create and initialize the Git repository:
<pre>$ git init --bare rit_git</pre>
</li>
<li> Create a <code>.ssh</code> directory
(if one does not already exist):
<pre>$ mkdir -p .ssh</pre>
</li>
<li> Use the <code>pico</code> text editor
to edit the "environment" file in the <code>.ssh</code> directory:
<pre>$ pico .ssh/environment</pre>
</li>
<li> Add the following line to the file:
<pre>PATH=/opt/csw/bin:/usr/bin</pre>
</li>
<li> Press <code>Ctrl-X + Y</code> to save.</li>
<li> Get the full path to your current directory:
<pre>$ pwd</pre>
</li>
<li> <b>Make sure to record the path!!
You will need it for the next few steps.</b>
</li>
<li> Open Eclipse and connect to your Git repository:
<ol type="a">
<li>Select <code>Window -> Open Perspective -> Other -> Git
</code>.
</li>
<li> Click the drop-down arrow in the top-right corner of
the <code>Git Repositories</code> pane and select
<code>Clone a Repository</code> from the list of options.
</li>
<li> Enter the following information and
then click <code>Finish</code>:
<pre>Host: glados.cs.rit.edu
Repository Path: {path_from_pwd}/rit_git
User: {CS_username}
Password: {CS_password}
Connection Type: ssh</pre>
(select checkbox for <code>"Store in Secure Store"</code>)
<p>
<u>Note:</u> Replace <code>{path_from_pwd}</code> with
the string returned by the <code>pwd</code> command,
and <code>{CS_username}</code>
and <code>{CS_password}</code>
with your CS credentials.
</p>
<p>
<u>Note:</u> If asked about creating a
<code>.ssh/known_hosts</code> file, agree to it.
</p>
</li>
</ol>
</li>
</ol>
</p>
</div>
<!-- ====================================================================== -->
<h2>Committing A Project to a Git Repository</h2>
<div>
<ol>
<li>Change back to the Eclipse Java perspective by selecting
<code>Window -> Open Perspective -> Java</code>
</li>
<li>In the <code>Package Explorer</code> pane, right-click on any
project folder and select <code>Team -> Share Project</code>.
</li>
<li>Select "Git" and then click <code>Next</code>.</li>
<li>Select the repository you just created
and then click <code>Finish</code>.
</li>
<li>Right click on the project you just shared
and select <code>Team -> Commit</code>.
</li>
<li>Enter a meaningful commit message (i.e. "Initial commit"),
select the files you wish to include in the commit,
and click <code>Commit</code>.
</li>
<li>Right click on the project again
and select <code>Team -> Push Branch</code>.
</li>
<li>Make a small change to the project
and make a second commit.
</li>
<li>This time, after selecting the files to commit,
click <code>Commit and Push</code>.
From now on, whenever you want to send your changes to the remote repository,
you need to use this button instead of the <code>Commit</code> button.
</li>
<li>On your local filesystem,
navigate to the <code>rit_git</code> folder
where your program files reside and verify that the file you changed
is present and correct.
This folder is where Eclipse keeps its working copy of
the version-controlled content.
When you commit through Eclipse, the commit uses this as the source
for a new version stored in the project's reposity folder under
<code>$HOME/rit_git/</code>.
</li>
</ol>
<p><u>Note:</u> You should never attempt to add, modify, or delete any files
in the <code>$HOME/rit_git/</code> directory.
Doing so would make Git "detect" corruption
and refuse to fetch or recover your files!
</p>
</div>
<!-- ====================================================================== -->
<h2>Checking Out a Project from a Git Repository</h2>
<div>
<p>
The advantage of using a source code repository
is that you can work on code on different machines and still
keep everything synchronized.
Each time you complete a coding session,
just commit and push your changes to the remote repository.
</p>
<p>
Then, next time you work on a different machine,
you can either check out the project (for the first time)
or pull any changes from the repository.
</p>
<p>
For example, you can start an assignment on a CS lab machine,
commit and push your changes,
and then go home and check out the project on your personal machine
to continue working right where you left off
(even if you use a different operating system)!
</p>
<p>
To check out a project for the first time in Eclipse:
<ol>
<li> Select <code>Window -> Open Perspective -> Other -> Git</code>.
</li>
<li> In the <code>Git Repositories</code> pane,
turn the arrow for the repository icon and the
<code>Working Directory</code> down.
This will reveal all of your projects in that repository.
</li>
<li>
Right-click on the project you want and select
<code>Import Projects</code>.
</li>
</ol>
</p>
<p>
Alternatively, to update a project within Eclipse that is
already checked out from Git:
<ol>
<li> In the <code>Package Explorer</code> perspective,
right-click on the project folder
and select <code>Team -> Pull</code>.
</li>
</ol>
</p>
</div>
<!-- ====================================================================== -->
</body>
</html>