Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1dad66b227f1a62908a1e4b1216ae92a87c5dee6 (plain) (blame)
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?xml version='1.0' encoding='utf-8' ?><!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"/>
		<title>EGit User Guide</title>
		<link type="text/css" rel="stylesheet" href="../../book.css"/>
	</head>
	<body>
		<table class="navigation" style="width: 100%;" border="0" summary="navigation">
			<tr>
				<th style="width: 100%" align="center" colspan="3">EGit User Guide</th>
			</tr>
			<tr>
				<td style="width: 20%" align="left"></td>
				<td style="width: 60%" align="center"></td>
				<td style="width: 20%" align="right">
					<a href="Concepts.html" title="Concepts">
						<img alt="Next" border="0" src="../../images/next.gif"/>
					</a>
				</td>
			</tr>
			<tr>
				<td style="width: 20%" align="left" valign="top"></td>
				<td style="width: 60%" align="center"></td>
				<td style="width: 20%" align="right" valign="top">Concepts</td>
			</tr>
		</table><hr/>
		<h1 id="Getting_Started">Getting Started</h1>
		<h2 id="Overview">Overview</h2>
		<p>If you're new to Git or distributed version control systems generally, then you might want to read 
			<a href="../../EGit/Git_For_Eclipse_Users/Git-For-Eclipse-Users.html" title="EGit/Git For Eclipse Users">Git for Eclipse Users</a> first. If you need more details and background read the 
			<a href="http://book.git-scm.com" target="egit_external">Git Community Book</a> or 
			<a href="http://progit.org/book/" target="egit_external">Git Pro</a>.
		</p>
		<h2 id="Basic_Tutorial:_Adding_a_project_to_version_control">Basic Tutorial: Adding a project to version control</h2>
		<h3 id="Configuration">Configuration</h3>
		<ul>
			<li>First you need to tell Git about yourself, click 
				<b>Preferences &gt; Team &gt; Git &gt; Configuration</b>
			</li>
			<li>Click 
				<b>New Entry</b> and enter the key value pairs <code>user.email</code> and <code>user.name</code>
			</li>
			<li>This information is stored in <code>~/.gitconfig</code> and will be used by Git to identify who did change the history of the repository whenever you are the user logged on to your computer.</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-email.png"/>
		</p>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-name.png"/>
		</p>
		<h3 id="Create_Repository">Create Repository</h3>
		<ul>
			<li>Create a new Java project <code>HelloWorld</code> </li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-project.png"/> 
		</p>
		<ul>
			<li>Select the project, click 
				<b>File &gt; Team &gt; Share Project</b> 
			</li>
			<li>Select repository type 
				<b>Git</b> and click 
				<b>Next</b>
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-share.png"/> 
		</p>
		<ul>
			<li>To configure the Git repository select the new project <code>HelloWorld</code> </li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-create-project.png"/> 
		</p>
		<ul>
			<li>Click 
				<b>Create Repository</b> to initialize a new Git repository for the <code>HelloWorld</code> project. If your project already resides in the working tree of an exisiting Git repository the repository is chosen automatically. 
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-project-created.png"/> 
		</p>
		<ul>
			<li>Click 
				<b>Finish</b> to close the wizard. 
			</li>
			<li>The decorator text "&#91;master&#93;" behind the project shows that this project is tracked in a repository on the 
				<i>master</i> branch and the question mark decorators show that the <code>.classpath</code> and <code>.project</code> and the <code>.settings</code> files are not yet under version control 
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-shared-project.png"/> 
		</p>
		<h3 id="Track_Changes">Track Changes</h3>
		<ul>
			<li>Click 
				<b>Team &gt; Add</b> on the project node 
			</li>
			<li>The 
				<i>+</i> decorators show that now the project's files have been added to version control 
			</li>
		</ul>
		<ul>
			<li>Create a file <code>.gitignore</code> in the project folder with the following content</li>
		</ul>
		<pre>bin 
</pre>
		<ul>
			<li>This excludes the <code>bin</code> folder from Git's list of tracked files. </li>
			<li>Add <code>.gitignore</code> to version control. </li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-ignore-added.png"/> 
		</p>
		<ul>
			<li>Click 
				<b>Team &gt; Commit</b> in the project context menu
			</li>
			<li>Enter a commit message explaining your change, the first line (followed by an empty line) will become the short log for this commit. By default the author and committer are taken from the <code>.gitconfig</code> file in your home directory. </li>
			<li>You may click 
				<b>Add Signed-off-by</b> to add a 
				<i>Signed-off-by:</i> tag. 
			</li>
			<li>If you are committing the change of another author you may alter the author field to give the name and email address of the author. </li>
			<li>Click 
				<b>Commit</b> to commit your first change. 
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-commit.png"/> 
		</p>
		<ul>
			<li>Note that the decorators of the committed files changed. </li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-commited.png"/> 
		</p>
		<h3 id="Inspect_History">Inspect History</h3>
		<ul>
			<li>Click 
				<b>Show In &gt; History</b> from the context menu to inspect the history of a resource 
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-history1.png"/> 
		</p>
		<ul>
			<li>Create a new Java class <code>Hello.java</code> and implement it </li>
			<li>Add it to version control and commit your change </li>
			<li>Improve your implementation and commit the improved class </li>
			<li>The resource history should now show 2 commits for this class</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-application.png"/> 
		</p>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-history2.png"/>
		</p>
		<ul>
			<li>Click the 
				<b>Compare Mode</b> toggle button in the History View
			</li>
			<li>Double click <code>src/Hello.java</code> in the Resource History View to open your last committed change in the Compare View </li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.9-getstarted-compare.png"/>
		</p>
		<p>
			<br/>

			<b>Congratulations, you just have mastered your first project using Git !</b>

			<br/>
			<br/>
		</p>
		<h2 id="Github_Tutorial">Github Tutorial</h2>
		<h3 id="Create_Local_Repository">Create Local Repository</h3>
		<ul>
			<li>follow 
				<a href="http://wiki.eclipse.org/EGit/User_Guide/Getting_Started" title="EGit/User Guide/Getting Started" target="egit_external">EGit/User Guide/Getting Started</a> to create a new local repository (with your content instead of the demo project)
			</li>
		</ul>
		<h3 id="Create_Repository_at_GitHub">Create Repository at GitHub</h3>
		<ul>
			<li>create a new repository at GitHub</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-create-repo.png"/> 
		</p>
		<p>On the next screen you can see the URLs you may use to access your fresh new repository:</p>
		<ul>
			<li>click 
				<b>SSH</b> to choose the 
				<i>SSH protocol</i>. It can be used for read and write access
			</li>
			<li>click 
				<b>HTTP</b> to choose the 
				<i>HTTP protocol</i>. It can also be used for read and write access.
			</li>
			<li>click 
				<b>Git Read-Only</b> to choose the anonymous 
				<i>git protocol</i> for cloning. It's the most efficient protocol git supports. Since the 
				<i>git protocol</i> doesn't support authentication it's usually used to provide efficient read-only access to public repositories.
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-cloneurl.png"/>
		</p>
		<h3 id="Eclipse_SSH_Configuration">Eclipse SSH Configuration</h3>
		<ul>
			<li>Open the Eclipse 
				<b>Preferences</b> and ensure that your SSH2 home is configured correctly (usually this is <tt>~/.ssh</tt>) and contains your SSH2 keys 
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-ssh-preferences.png"/> 
		</p>
		<ul>
			<li>if you don't have SSH keys yet you may generate them on the second tab 
				<b>Key Management</b> of this dialog, use a good pass phrase to protect your private key, for more details see 
				<a href="http://help.github.com/working-with-key-passphrases/" target="egit_external">"working with key passphrases"</a>
			</li>
			<li>upload your public SSH key to your 
				<a href="https://github.com/account" target="egit_external">GitHub account settings</a>
			</li>
		</ul>
		<h3 id="Push_Upstream">Push Upstream</h3>
		<ul>
			<li>Click 
				<b>Team &gt; Push...</b> and copy and paste the SSH URL of your new github repository
			</li>
			<li>If you are behind a firewall which doesn't allow SSH traffic use the github HTTPS URL instead and provide your github user and password instead of using the uploaded public SSH key. To store your credentials into the Eclipse secure store click 
				<b>Store in Secure Store</b>. 
			</li>
			<li>
				<b>Note:</b> many HTTP proxies are configured to block HTTP URLs containing a user name, since disclosing a user name in an HTTP URL is considered a security risk. In that case remove the username from the HTTP URL and only provide it in the user field. It will be sent as an HTTP header.
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-pushurl.png"/>
		</p>
		<ul>
			<li>Click 
				<b>Next</b> and on first connection accept GitHub's host key.
			</li>
		</ul>
		<ul>
			<li>Enter your SSH key's passphrase and click 
				<b>OK</b>.
			</li>
		</ul>
		<ul>
			<li>On the next wizard page click 
				<b>Add all branches spec</b> to map your local branch names 1:1 to the same branch names in the destination repository.
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-push-refspec.png"/> 
		</p>
		<ul>
			<li>Click 
				<b>Next</b>. The push confirmation dialog will show a preview of the changes that will be pushed to the destination repository.
			</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-push-preview.png"/>
		</p>
		<ul>
			<li>Click 
				<b>Finish</b> to confirm that you want to push these changes.
			</li>
		</ul>
		<ul>
			<li>The next dialog reports the result of the push operation.</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-pushresult.png"/>
		</p>
		<ul>
			<li>Point your browser at your GitHub repository to see that your new repository content has arrived</li>
		</ul>
		<p>
			<img border="0" src="images/Egit-0.10-github-pushed-repo.png"/>
		</p><hr/>
		<table class="navigation" style="width: 100%;" border="0" summary="navigation">
			<tr>
				<td style="width: 20%" align="left"></td>
				<td style="width: 60%" align="center"></td>
				<td style="width: 20%" align="right">
					<a href="Concepts.html" title="Concepts">
						<img alt="Next" border="0" src="../../images/next.gif"/>
					</a>
				</td>
			</tr>
			<tr>
				<td style="width: 20%" align="left" valign="top"></td>
				<td style="width: 60%" align="center"></td>
				<td style="width: 20%" align="right" valign="top">Concepts</td>
			</tr>
		</table>
	</body>
</html>

Back to the top