EGit User Guide | ||
---|---|---|
Concepts |
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.
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.
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:
user.email
and user.name
Add the environment variable HOME
to your environment variables.
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.
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.
HelloWorld
. (In this case, the project was built outside of your Eclipse Workspace.)
HelloWorld
.
HelloWorld
project. If your project already resides in the working tree of an existing Git repository the repository is chosen automatically.
.classpath
and .project
and the .settings
files are not yet under version control.
.gitignore
in the project folder with the following content:
/bin
bin
folder from Git's list of tracked files..gitignore
to version control (
Team > Add):
.gitignore
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.
.gitignore
.
.gitconfig
file in your home directory.
Hello.java
and implement it.
src/Hello.java
in the Resource list of the History View to open your last committed change in the Compare View.
Congratulations, you just have mastered your first project using Git !
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:
On the next screen you can see the URLs you may use to access your fresh new repository:
Further information about advanced SSH configuration (such as using Putty or another SSH agent with EGit) is available in the EGit FAQ (section SSH).
Find all exercises and the slides here.
Follow the exercise #1 to prepare for the Git Tutorial.
Concepts |