Update documentation for 3.5.0
[egit/eclipse.git] / org.eclipse.egit.doc / help / EGit / User_Guide / User-Guide.html
blob2b7901fdc324a3f423ff0098835ebc7961a5b7e1
1 <?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">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5 <title>EGit User Guide</title>
6 <link type="text/css" rel="stylesheet" href="../../book.css"/>
7 </head>
8 <body>
9 <table class="navigation" style="width: 100%;" border="0" summary="navigation">
10 <tr>
11 <th style="width: 100%" align="center" colspan="3">EGit User Guide</th>
12 </tr>
13 <tr>
14 <td style="width: 20%" align="left"></td>
15 <td style="width: 60%" align="center"></td>
16 <td style="width: 20%" align="right">
17 <a href="Concepts.html" title="Concepts">
18 <img alt="Next" border="0" src="../../images/next.gif"/>
19 </a>
20 </td>
21 </tr>
22 <tr>
23 <td style="width: 20%" align="left" valign="top"></td>
24 <td style="width: 60%" align="center"></td>
25 <td style="width: 20%" align="right" valign="top">Concepts</td>
26 </tr>
27 </table><hr/>
28 <h1 id="Getting_Started">Getting Started</h1>
29 <h2 id="Overview">Overview</h2>
30 <p>If you're new to Git or distributed version control systems generally, then you might want to read
31 <a href="../../EGit/Git_For_Eclipse_Users/Git-For-Eclipse-Users.html" title="EGit/Git For Eclipse Users">Git for Eclipse Users</a> first. More background and details can be found in the on-line book
32 <a href="http://progit.org/book/" target="egit_external">Pro Git</a>.
33 </p>
34 <p>If you are coming from CVS, you can find common CVS workflows for Git
35 <a href="http://wiki.eclipse.org/Platform-releng/Git_Workflows" title="Platform-releng/Git Workflows" target="egit_external">Platform-releng/Git Workflows</a>.
36 </p>
37 <h2 id="Basic_Tutorial:_Adding_a_project_to_version_control">Basic Tutorial: Adding a project to version control</h2>
38 <h3 id="Configuration">Configuration</h3>
39 <h4 id="Identifying_yourself">Identifying yourself</h4>
40 <p>Whenever the history of the repository is changed (technically, whenever a commit is created), Git keeps track of the user who created that commit. The identification consists of a name (typically a person's name) and an e-mail address. This information is stored in file <code>~/.gitconfig</code> under dedicated keys.
41 <br/>
42 </p>
43 <p>EGit will ask you for this information when you create your first commit. By default, this dialog is shown only once until you create a new workspace or tick the checkbox "Show initial configuration dialog" on the Git Preference page:</p>
44 <p>
45 <img border="0" src="images/Egit-0.11-initialConfigurationDialog.png"/>
46 </p>
47 <p>You can also untick "Don't show this dialog again" if you want to see it again later.</p>
48 <p>Instead of using this dialog, you can always change this information using the Git configuration:
49 <br/>
50 </p>
51 <ul>
52 <li>Click
53 <b>Preferences &gt; Team &gt; Git &gt; Configuration</b>
54 </li>
55 <li>Click
56 <b>New Entry</b> and enter the key value pairs <code>user.email</code> and <code>user.name</code>
57 <br/>
58 </li>
59 </ul>
60 <p>
61 <img border="0" src="images/Egit-0.9-getstarted-email.png"/>
62 </p>
63 <p>
64 <img border="0" src="images/Egit-0.9-getstarted-name.png"/>
65 </p>
66 <h4 id="Setting_up_the_Home_Directory_on_Windows">Setting up the Home Directory on Windows</h4>
67 <p>Add the environment variable <code>HOME</code> to your environment variables.</p>
68 <ol>
69 <li>In Windows 7, type "environment" at the start menu.</li>
70 <li>Select "Edit environment variables for your account".</li>
71 <li>Click the "New" button.</li>
72 <li>Enter "HOME" in the name field.</li>
73 <li>Enter "%USERPROFILE%" or some other path in the value field.</li>
74 <li>Click OK, and OK again. You have just added the Home directory on Windows.&lt;br /&gt;</li>
75 </ol>
76 <p>Note that if you use
77 <a href="http://www.cygwin.com/" target="egit_external">Cygwin</a>, you should already have <code>HOME</code> set. For example, if you installed Cygwin to <code>C:\cygwin</code> and your username is Fred, then Cygwin should have already set <code>HOME</code> to <code>C:\cygwin\home\Fred</code> (or something similar). You can verify this by entering <code>echo %HOME%</code> in the Windows command prompt, or <code>echo $HOME</code> in the Cygwin shell.
78 </p>
79 <p>EGit needs this path for looking up the user configuration (.gitconfig). <code>HOME</code> should point to your home directory e.g. <code>C:\Users\Tom</code>.
80 <b>Ensure correct case!</b> E.g. <code>C:\users</code> instead of <code>C:\Users</code> may cause problems!
81 </p>
82 <p>If the <code>HOME</code> variable is not defined the home directory will be calculated by concatenating <code>HOMEDRIVE</code> and <code>HOMEPATH</code>.</p>
83 <p>If both <code>HOME</code> and <code>HOMEDRIVE</code> are not defined <code>HOMESHARE</code> will be used.</p>
84 <p>EGit shows a warning if <code>HOME</code> is not defined explicitly. Keep in mind that if you set the HOME environment variable while Eclipse is running, you will still see following warning. You will have to restart Eclipse for it to recognize the HOME value.</p>
85 <p>
86 <img border="0" src="images/Egit_no_home.png"/>
87 </p>
88 <h4 id="Pointing_out_the_System_wide_configuration">Pointing out the System wide configuration</h4>
89 <p>If you use Git for Windows as a companion to EGit, make sure EGit knows where Git is installed so it can find the "system wide settings", e.g. how core.autocrlf is set. Go to the settings and look under Team&gt;Git&gt;Configuration and then the System Settings tab. </p>
90 <p>If you selected one of the options to use Git from the Command Line Prompt when you installed Git for Windows, then the location of the system
91 wide settings is filled in with a path and everything is fine. If not, use the Browse button to locate where Git is installed, e.g. C:\Program Files(x86)\Git. </p>
92 <p>This advice also applies to users of other Git packagings, e.g. Git under Cygwin or TortoiseGit.</p>
93 <p>Non-Windows users should in theory check this setting, but the system wide settings are usually not used on non-Windows platforms.</p>
94 <h3 id="Create_Repository">Create Repository</h3>
95 <ul>
96 <li>Create a new Java project <code>HelloWorld</code>. (In this case, the project was built outside of your Eclipse Workspace.)</li>
97 </ul>
98 <p>
99 <img border="0" src="images/Egit-0.9-getstarted-project.png"/>
100 </p>
101 <ul>
102 <li>Select the project, click
103 <b>File &gt; Team &gt; Share Project</b>.
104 </li>
105 <li>Select repository type
106 <b>Git</b> and click
107 <b>Next</b>.
108 </li>
109 </ul>
111 <img border="0" src="images/Egit-0.9-getstarted-share.png"/>
112 </p>
113 <ul>
114 <li>To configure the Git repository select the new project <code>HelloWorld</code>.</li>
115 </ul>
117 <img border="0" src="images/Egit-0.9-getstarted-create-project.png"/>
118 </p>
119 <ul>
120 <li>Click
121 <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 existing Git repository the repository is chosen automatically.
122 </li>
123 </ul>
125 <img border="0" src="images/Egit-0.9-getstarted-project-created.png"/>
126 </p>
127 <ul>
128 <li>Click
129 <b>Finish</b> to close the wizard.
130 </li>
131 <li>The decorator text "
132 <a href="master">master</a>" behind the project shows that this project is tracked in a repository on the
133 <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.
134 </li>
135 </ul>
137 <img border="0" src="images/Egit-0.9-getstarted-shared-project.png"/>
138 </p>
139 <h3 id="Track_Changes">Track Changes</h3>
140 <ul>
141 <li>Click
142 <b>Team &gt; Add</b> on the project node. (This menu item may read
143 <b>Add to Index</b> on recent versions of Egit.)
144 </li>
145 <li>The
146 <i>+</i> decorators show that now the project's files have been added to version control.
147 </li>
148 <li>Mark the "bin" folder as "ignored by Git", either by right-clicking on it and selecting
149 <b>Team &gt; Ignore</b> or by creating a file <code>.gitignore</code> in the project folder with the following content:
150 </li>
151 </ul>
152 <pre>/bin
153 </pre>
154 <ul>
155 <li>This excludes the <code>bin</code> folder from Git's list of tracked files.</li>
156 <li>Add <code>.gitignore</code> to version control (
157 <b>Team &gt; Add</b>):
158 </li>
159 </ul>
161 <img border="0" src="images/Egit-0.11-getstarted-ignore-added.png"/>
162 </p>
163 <ul>
164 <li>You may have to set your Package Explorer filters in order to see <code>.gitignore</code> displayed in the Package Explorer. To access filters, select the down arrow on the right edge of the Package Explorer tab to display View Menu.</li>
165 </ul>
167 <img border="0" src="images/Pe_downarrow1.png"/>
168 </p>
169 <ul>
170 <li>Select
171 <b>Filters...</b> from the View Menu and you will be presented with the Java Element Filters dialog. Unselect the top entry to display files that begin with . (period) such as <code>.gitignore</code>.
172 </li>
173 </ul>
174 <ul>
175 <li>Click
176 <b>Team &gt; Commit</b> in the project context menu.
177 </li>
178 <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>
179 <li>You may click
180 <b>Add Signed-off-by</b> to add a
181 <i>Signed-off-by:</i> tag.
182 </li>
183 <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>
184 <li>Click
185 <b>Commit</b> to commit your first change.
186 </li>
187 </ul>
189 <img border="0" src="images/Egit-0.9-getstarted-commit.png"/>
190 </p>
191 <ul>
192 <li>Note that the decorators of the committed files have changed as a result of your commit.</li>
193 </ul>
195 <img border="0" src="images/Egit-0.9-getstarted-commited.png"/>
196 </p>
197 <h3 id="Inspect_History">Inspect History</h3>
198 <ul>
199 <li>Click
200 <b>Team &gt; Show in History</b> from the context menu to inspect the history of a resource:
201 </li>
202 </ul>
204 <img border="0" src="images/Egit-0.11-getstarted-history1.png"/>
205 </p>
206 <ul>
207 <li>Create a new Java class <code>Hello.java</code> and implement it.</li>
208 <li>Add it to version control and commit your change.</li>
209 <li>Improve your implementation and commit the improved class.</li>
210 <li>The resource history should now show 2 commits for this class.</li>
211 </ul>
213 <img border="0" src="images/Egit-0.9-getstarted-application.png"/>
214 </p>
216 <img border="0" src="images/Egit-0.11-getstarted-history2.png"/>
217 </p>
218 <ul>
219 <li>Click the
220 <b>Compare Mode</b> toggle button in the History View.
221 </li>
222 <li>Double click <code>src/Hello.java</code> in the Resource list of the History View to open your last committed change in the Compare View.</li>
223 </ul>
225 <img border="0" src="images/Egit-0.11-getstarted-compare.png"/>
226 </p>
228 <br/>
230 <b>Congratulations, you just have mastered your first project using Git&nbsp;!</b>
232 <br/>
233 <br/>
234 </p>
235 <h2 id="GitHub_Tutorial">GitHub Tutorial</h2>
236 <h3 id="Create_Local_Repository">Create Local Repository</h3>
237 <ul>
238 <li>follow
239 <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).
240 </li>
241 </ul>
242 <h3 id="Create_Repository_at_GitHub">Create Repository at GitHub</h3>
243 <ul>
244 <li>create a new repository at GitHub:</li>
245 </ul>
247 <img border="0" src="images/Egit-0.10-github-create-repo.png"/>
248 </p>
249 <p>On the next screen you can see the URLs you may use to access your fresh new repository:</p>
250 <ul>
251 <li>click
252 <b>SSH</b> to choose the
253 <i>SSH protocol</i>. It can be used for read and write access.
254 </li>
255 <li>click
256 <b>HTTP</b> to choose the
257 <i>HTTP protocol</i>. It can also be used for read and write access.
258 </li>
259 <li>click
260 <b>Git Read-Only</b> to choose the anonymous
261 <i>git protocol</i> for cloning. It's the most efficient protocol git supports. Since the
262 <i>git protocol</i> doesn't support authentication it's usually used to provide efficient read-only access to public repositories.
263 </li>
264 </ul>
266 <img border="0" src="images/Egit-0.10-github-cloneurl.png"/>
267 </p>
268 <h3 id="Eclipse_SSH_Configuration">Eclipse SSH Configuration</h3>
269 <ul>
270 <li>Open the Eclipse
271 <b>Preferences</b> and ensure that your SSH2 home is configured correctly (usually this is <tt>~/.ssh</tt>) and contains your SSH2 keys:
272 </li>
273 </ul>
275 <img border="0" src="images/Egit-0.10-ssh-preferences.png"/>
276 </p>
277 <ul>
278 <li>if you don't have SSH keys yet you may generate them on the second tab of this dialog (
279 <b>Key Management</b>). Use a good pass phrase to protect your private key, for more details see
280 <a href="http://help.github.com/working-with-key-passphrases/" target="egit_external">"working with key passphrases"</a>.
281 </li>
282 <li>upload your public SSH key to your
283 <a href="https://github.com/account" target="egit_external">GitHub account settings</a>.
284 </li>
285 </ul>
286 <p>Further information about advanced SSH configuration (such as using Putty or another SSH agent with EGit) is available in the
287 <a href="http://wiki.eclipse.org/EGit/FAQ#SSH_config" title="EGit/FAQ#SSH_config" target="egit_external">EGit FAQ (section SSH)</a>.
288 </p>
289 <h3 id="Push_Upstream">Push Upstream</h3>
290 <ul>
291 <li>Click
292 <b>Team &gt; Remote &gt; Push...</b> and copy and paste the SSH URL of your new GitHub repository.
293 </li>
294 <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
295 <b>Store in Secure Store</b>.
296 </li>
297 <li>
298 <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 user name from the HTTP URL and only provide it in the user field. It will be sent as an HTTP header.
299 </li>
300 </ul>
302 <img border="0" src="images/Egit-0.10-github-pushurl.png"/>
303 </p>
304 <ul>
305 <li>Click
306 <b>Next</b> and on first connection accept GitHub's host key.
307 </li>
308 </ul>
309 <ul>
310 <li>Enter your SSH key's passphrase and click
311 <b>OK</b>.
312 </li>
313 </ul>
314 <ul>
315 <li>On the next wizard page click
316 <b>Add all branches spec</b> to map your local branch names to the same branch names in the destination repository (on a one-to-one basis).
317 </li>
318 </ul>
320 <img border="0" src="images/Egit-0.10-github-push-refspec.png"/>
321 </p>
322 <ul>
323 <li>Click
324 <b>Next</b>. The push confirmation dialog will show a preview of the changes that will be pushed to the destination repository.
325 </li>
326 </ul>
328 <img border="0" src="images/Egit-0.10-github-push-preview.png"/>
329 </p>
330 <ul>
331 <li>Click
332 <b>Finish</b> to confirm that you want to push these changes.
333 </li>
334 </ul>
335 <ul>
336 <li>The next dialog reports the result of the push operation.</li>
337 </ul>
339 <img border="0" src="images/Egit-0.10-github-pushresult.png"/>
340 </p>
341 <ul>
342 <li>Point your browser at your GitHub repository to see that your new repository content has arrived.</li>
343 </ul>
345 <img border="0" src="images/Egit-0.10-github-pushed-repo.png"/>
346 </p>
348 <br/>
349 </p>
350 <h2 id="EclipseCon_2012_Git_Tutorial">EclipseCon 2012 Git Tutorial</h2>
351 <p>Find all exercises and the slides
352 <a href="https://docs.google.com/open?id=0B4F_gjXVrHZVRXkydE0xVFBRRkc1WUpEcXdwQ2I1dw" target="egit_external">here</a>.
353 </p>
354 <p>Follow the
355 <a href="https://docs.google.com/document/d/1UCbNCvljiInc6-vwBsHHzOQ1ItC10f1bFAOi8T30DJ8/edit" target="egit_external">exercise #1</a> to prepare for the Git Tutorial.
356 </p><hr/>
357 <table class="navigation" style="width: 100%;" border="0" summary="navigation">
358 <tr>
359 <td style="width: 20%" align="left"></td>
360 <td style="width: 60%" align="center"></td>
361 <td style="width: 20%" align="right">
362 <a href="Concepts.html" title="Concepts">
363 <img alt="Next" border="0" src="../../images/next.gif"/>
364 </a>
365 </td>
366 </tr>
367 <tr>
368 <td style="width: 20%" align="left" valign="top"></td>
369 <td style="width: 60%" align="center"></td>
370 <td style="width: 20%" align="right" valign="top">Concepts</td>
371 </tr>
372 </table>
373 </body>
374 </html>