Create a New Project Under Git Version Control

Create a new project in Eclipse ideLesson4.

Right click you project in the package explorer. Find

Figure 4.4. First Git Project, One

First Git Project, One

Select Git, click Next

Figure 4.5. First Git Project, Two

First Git Project, Two

Click Create …

Figure 4.6. First Git Project, Three

First Git Project, Three

Give your a repository a name and then click Finish.

Figure 4.7. First Git Project, Four

First Git Project, Four

Click Create Repository. The package explorer should after a refresh show the repository name in square brackets.

Figure 4.8. First Git Project, Five

First Git Project, Five

In Git as in other similar systems, you must decide what you place under it's control. Regarding project development you are interested in maintaining source code integrity between versions. Therefore you are interested in Git managing source code, not binary code for execution. In order to achieve this, you must create a file .gitignore in your project folder. The file content:

bin

and nothing else. This means that the bin subfolder of your project will be ignored by Git. In other words Git will look into src.

Right click and then Team->Add to index. There will be an asterisk next to the project name. Then right click and Commit.

Figure 4.9. First Git Project, Six

First Git Project, Six

Check with Team->Show in history.

Figure 4.10. First Git Project, Seven

First Git Project, Seven

Now finally, in your project: in a package helloGit create a new class GiTest

        <xi:include></xi:include>
      

Once the class is in place, you may want to commit it to the repository. You will want to do the same after changes. Team->Commit gives you:

Figure 4.11. First Git Project, Eight

First Git Project, Eight

If there has been no changes you will get:

Figure 4.12. First Git Project, Nine

First Git Project, Nine

The repository file structure now in place, looks as follows

nml@mymb ~/git $ tree ideLesson4n
ideLesson4n
└── ideLesson4n
    ├── bin
    │   └── helloGit
    │       └── GiTest.class
    └── src
        └── helloGit
            └── GiTest.java

5 directories, 2 files
nml@mymb ~/git $