Getting Started

Overview

If you're new to Git or distributed version control systems generally, then you might want to read Git for Eclipse Users first. More background and details can be found in the on-line book Pro Git.

If you are coming from CVS, you can find common CVS workflows for Git Platform-releng/Git Workflows.

The Preferences Dialog

Many of the configurations you will make in Eclipse are found in the Preferences Dialog. To open the Preference Dialog click Window > Preferences in the menu bar at the top. To see the preferences for git, click Team > Git in the tree on the left.

Basic Tutorial: Adding a project to version control

Configuration

Identifying yourself

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 ~/.gitconfig under dedicated keys.

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:

You can also untick "Don't show this dialog again" if you want to see it again later.

Instead of using this dialog, you can always change this information using the Git configuration:

Setting up the Home Directory on Windows

Add the environment variable HOME to your environment variables.

  1. In Windows 7, type "environment" at the start menu.
  2. Select "Edit environment variables for your account".
  3. Under "User Variables", click the "New" button.
  4. Enter "HOME" in the name field.
  5. Enter "%USERPROFILE%" or some other path in the value field.
  6. Click OK, and OK again. You have just added the Home directory on Windows.<br />
  7. File > Exit, then restart the application.

Note that if you use Cygwin, you should already have HOME set. For example, if you installed Cygwin to C:\cygwin and your username is Fred, then Cygwin should have already set HOME to C:\cygwin\home\Fred (or something similar). You can verify this by entering echo %HOME% in the Windows command prompt, or echo $HOME in the Cygwin shell.

EGit needs this path for looking up the user configuration (.gitconfig). HOME should point to your home directory e.g. C:\Users\Tom. Ensure correct case! E.g. C:\users instead of C:\Users may cause problems!

If the HOME variable is not defined the home directory will be calculated by concatenating HOMEDRIVE and HOMEPATH.

If both HOME and HOMEDRIVE are not defined HOMESHARE will be used.

EGit shows a warning if HOME 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.

Pointing out the System wide configuration

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>Git>Configuration and then the System Settings tab.

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 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.

This advice also applies to users of other Git packagings, e.g. Git under Cygwin or TortoiseGit.

Non-Windows users should in theory check this setting, but the system wide settings are usually not used on non-Windows platforms.

Create Repository

Track Changes

/bin

Inspect History


Congratulations, you just have mastered your first project using Git !

GitHub Tutorial

Note: pushing to a GitHub repository via HTTPS or fetching from a private GitHub repository via HTTPS may ask you for your log-in credentials (username and password). Use a personal access token (PAT) as the password. Do not use your normal log-in password for your user account at GitHub!

You have to create the PAT first via the GitHub web UI. GitHub personal access tokens give you fine-grained control over what the token holder may do. This is done by assigning "scopes" to tokens. See the GitHub documentation for the details.

Some hints:

Create Local Repository

Create Repository at GitHub

On the next screen you can see the URLs you may use to access your fresh new repository:

Eclipse SSH Configuration

Further information about advanced SSH configuration (such as using Putty or another SSH agent with EGit) is available in the EGit FAQ (section SSH).

Push Upstream


EclipseCon 2012 Git Tutorial

Find all exercises and the slides here.

Follow the exercise #1 to prepare for the Git Tutorial.