BlueJ now supports Git repositories as part of its teamwork features. This tutorial briefly explains how to use the new Git support on Bluej.
In order to use Git functionalities you must first enable Teamwork functionalities by going to: Tools->Preferences and then in the "Interface" tab tick on "Show teamwork controls".
It is important to learn some basic Git terminology:
There are several web-based Git repository hosting service. They can be a good option if you want to very quickly and easily create repositories to host your BlueJ projects.
We talk about some of the most popular web-based Git repository hosting services below.
GitHub is one of the most popular a web-based Git repository hosting service. It provides a web-based graphical interface where you can see your repository, its files, commits, etc. It also provides forums where you can discuss features in your projects, and a wiki engine where you and your collaborators can create documentation for your project.
In order to use GitHub, you should create a completely empty repository. You can find tutorials on how to create your GitHub repository here (skip step 5: "Select Initialize this repository with a README.").
After your create a new repostory, GitHub shows a screen with the typical usage of the repository using the Git command line commands (Figure 1), but this should be ignored: BlueJ will will perform them automatically when checking out a project. Make note of the repository address (below the phrase: "Quick setup - if you've done this kind of thing before"): you will need to use it together with your GitHub username and password to share a project into or checkout a project from this repository (see the instructions in the following sections).
On GitHub we recommend you use the https URI, since BlueJ uses username and password authentication.
Bitbucket is a web-based Git repository hosting service, similar to GitHub. One of its differences from GitHub is that you can create free private repositories limited to 5 users.
You can find a tutorial on how to create a Git repository in Bitbucket here.
GitLab is an application to code, test and deploy code. It provides Git repository and has integrated code reviews, issue tracking, etc. Differently from GitHub and Bitbucket, it can be installed in your local network.
Given you have GitLab installed in your network, You can find a tutorial on how to create a Git repository here.
Once you have your empty Git repository set, you may want to share your BlueJ project with other users.
In order to do so, open the existing project you want to share. Select: Tools -> Team -> Share this project menu option (Figure 2). You should see a dialog similar to the one in Figure 3.
Select "Git" as your server type. This will allow you to enter:
Tip: It is good practice to click on the "Check connection" button: this button tests if BlueJ can connect to the remote repository and if the URI does contain a valid Git repository.
In order to open a project previously shared on a remote Git repository, you need to create a local clone of the remote Git repository (this operation should be done only once). This local clone of the project can later be open and used just like a normal BlueJ project. To create the local clone of the project in BlueJ you need to execute the command "check out project". It can be accessed by going to the menus: Tools->Team->Checkout project...
Then a dialog similar to the one in Figure 3 will appear.
Note: The Check out command in BlueJ is acutally performing a 'clone' operation to create a local copy of the repository, with the main branch checked out into the working copy.
You should select "Git" as your server type. This will allow you to enter:
Tip: Click on the "Check connection" button: this button tests if BlueJ can connect to the remote repository and if the URI does contain a valid Git repository.
After clicking on "OK", you should now select where you want BlueJ to checkout the project in your machine. You should choose a name for your project. The project name will be the folder's name.
Once you have a shared project, it is likely that either you or other users made changes to the project, therefore, it is important to know if you have changes that are ready to commit to your local repository, or changes ready put in the remote repository (push), or if you need to update your local project because someone made a change in the remote repository.
This information is presented on the status dialog, which can be displayed by pressing the "Status" button on BlueJ main screen (Figure 4)
You can see the status dialogue below:
The Figures 5 and 6 have three columns:
A file can have one of the following Local status:
A file can have one of the following Remote status:
In Figure 7, we show the commit/push window. In the window we can see a list of files ready to commit: These files have modified in some way since the last time an update was made: you may have delete some of them (Class2.java); or created new ones (NewClass.java).
You will need to write a comment in your commit: what are the new changes that you made in this commit? this is important as a way of describing what these changes do. This comment will be written in the repository log and are a useful way of quickly and clearly communicating your changes to other users.
The commit is done by pressing the Commit button. You don't need to be connected in order to make commits: Git is a distributed version control system, which means that you have a fully functional local repository inside your BlueJ project, and when you commit you are actually putting your changes to this local repository.
After commiting you changes to your local repository, they are ready to be pushed to the remote repository, where they can be shared by the other users. You can see the list of files ready to be pushed in Figure 5.
You need to be able to connect to the remote repository when you push. BlueJ may ask for the password to connect to the remote repository.
In big projects, or projects with many participants you may have a quite long history. For that purpose, we added two filters at the end of the window: "Show file" where we display only the commits that contains the selected file, and "Show user", where you can see the only the commits of the selected user.
Pressing the "Update" button on the man screen will open the update window (Figure 10), there you will see the list of files affected by this update. To update, you should press the "update" button.
Please see support page.