Hints for Using EGit

EGit is a plugin for Eclipse, which allows you to use Git source control from Eclipse. Eclipse, Git, and EGit are sophisticated power-user software tools, which is another way of saying that there are a lot of ways to do things wrong. The hints on this web page are intended to help beginners use EGit in a simplified way. For more information about EGit, see the EGit User Guide. For more information about Git, see git-hints.html and the Git User's Manual.

The Simplified Operating Procedure

This web page will assume that a group of users want to work on one project using EGit to develop and maintain a single code base (the "master branch"). Each user will have his/her own local repository (a copy of the code plus all the source control stuff). Each user will receive changes and send changes using a remote repository at GitHub (or some other site). In Git-speak receiving changes from the remote repository is called pull and sending changes is called push.

This web page assumes that the user updates the local repository at the same time as the remote repository, that is, each pull is simultaneously performed with a checkout (receiving changes from the local repository), and each push is simultaneously performed with a commit (sending changes to the local repository).

A typical coding session would be to:

Initial Configuration

EGit wants to know your name and email address. This should be the same email address that you use for github.com. In Eclipse:

New Repositories

Your instructor will set up the repositories on GitHub (or some other Git server) that you need, but this web page describes the steps that are needed to create a new repository using EGit.

The First Pull (Cloning the Repository)

This assumes that an Eclipse project exists on the remote repository, but not yet in the local repository (or in your Eclipse). In Git-speak, you want to clone a repository.

This also assumes that the remote repository is at GitHub, the GitHub organization is UTSA-CS-3443, and the repository name is reponame.git.

Before you can pull a repository (or repo) from GitHub, you need to register a free account on the github.com website. You will need to give the owner of UTSA-CS-3443 (e.g. your course instructor) your GitHub user name, so that the owner can add you as a member of the development team to work on the project stored in the repo. Assuming you have done that, then in Eclipse:

Pull

To pull changes from the remote repository:

Push

To push changes to the remote repository:

Resolving Merge Conflicts

If the Commit and Push resulted in this message:

rejected master -> master (non-fast-forward)

then you need to resolve a merge conflict. See this web page.

Gitignore Files

An Eclipse project will often generate files that you do not want to track with Git (or EGit). This typically includes the class files generated by the compiler and the files generated by javadoc. You can tell git to ignore certain files by creating a file called .gitignore in the top level of your project directory, with contents such as:

# ignore the bin and doc directories
bin/
doc/

# ignore class files and html files
*.class
*.html