You may need to share some projects with your development team. Moreover, you might want discard your modifications in a project and revert back to an older version. We recommend you to use Git, a distributed version control system that emphasizes speed and efficiency. In this page, we describe how to use EGit, a Git implementation used within the Eclipse IDE, for some typical use cases.
Note that you can also install git command-line software and other GUI tools. However, we will use EGit here.
This is not a tutorial on Git. However, a short description about Git is given. The full features of EGit are not covered either.
If you have not installed EGit, do the following steps:
Now let us open the Git Repositories view which is used to manage repositories:
You should see a window like the following figure.
An important thing to do before working with Git is to set your name and email which are used to identify who do changes.
If you already familiar with Git, you can skip this section. This part is not intended to describe Git in detail. Read the Git Pro book by Scott Chacon, if you want to learn more. Git is a Distributed Version Control System (DVCS) which handles data differently than most other VCSs. Usually, VCSs store information as a set of files and the changes made to each file over time. In Git, every repository has a complete history and full revision tracking capabilities. Fig 1-4 (How other VCSs store data) and Fig 1-5 (How Git store data) in the Git Pro book illustrate this difference. Git is also a fully distributed VCS. It does not depend on a central server nor network access.
A repository can contain several projects. In EGit, these should be Eclipse projects and for us projects or libraries containing building blocks. We recommend one Git repository contains one project in order to be able to maintain your projects easily. In this documentation, we assume this is the case. In order to share a project with your development team, you need to store the content of your local repository in your machine in a remote location (a Git server or a hosting service). Obtaining a shared project is achieved by getting a copy of an upstream or a remote repository into your machine.
A Git repository also contains the history of its content, i.e., a project. The Git working directory is a single checkout of one version of the project. If the project is also in your Eclipse workspace, the version in the workspace is the same as the one in the working directory. Relations among local repository, remote repository, working directory and the Eclipse workspace can be depicted in the following figure. They will be explained further with four typical use cases.
You can use a hosting provider for Git projects to store a copy of your repository remotely and share it with your development team. There are several providers, e.g., Github and Bitbucket. Here, we use Bitbucket. To use Bitbucket hosting service, you need to create an account.
We can use HTTPS or SSH for the communication protocol between local repository and Bitbucket. To use HTTPS you need to supply your username and password. To use SSH, you need to set up an RSA key pair if you do not have them. Here, we will use HTTPS.
We show four cases, namely: