
Adding a project to Git
Git is a distributed repository. Unlike some of the other source management systems, Git maintains the complete local repository too. So you can perform activities such as check-out and check-in in the local repository without connecting to any remote repository. When you are ready to move your code to a remote repository, you can connect to it and push your files to the remote repository.
If you are new to Git, take a look at the following documentation and tutorial:
https://git-scm.com/doc and https://www.atlassian.com/git/tutorials/.
To learn how to add a project to Git, let's create a simple Java project in the workspace. Again as in the previous section, what code you write in this project is not important for now:
- Create a Java class in the project.
- To add this project to Git, right-click on the project in Package Explorer or Navigator and select Team | Share Project...:

Figure 3.17: Sharing an Eclipse project with Git
- Select Git and click Next. Check the box Use or create repository in parent folder of project.
- Select the project (check the box for the project) and click the Create Repository button. Then click Finish:

Figure 3.18: Creating a Git repository for a project
- This creates a new Git repository in the project folder. Switch to the Git perspective (or open the Git Repositories view from the Window | Show View | Other option) and you should see the project listed in the Git Repositories view (see the following screenshot):

Figure 3.19: Git Repositories view