Author: DheerajK_81 Version: **
Do the following to set up and use Git for an Eclipse project in ModusToolbox™:
Step1: Updating the Git plugin
ModusToolbox comes with Git (v4.8.0) integration by default. To get the latest plugin, use Help > Install New Software and add http://download.eclipse.org/egit/updates as shown:
The window that appears lists the available Git plugins that can updated/installed. Select the required plugins and click Next.
Follow the onscreen instructions, accept the license agreement, and complete the installation. Now, restart ModusToolbox for the changes to take effect.
Step 2: Adding projects to Git
Select the projects you want to add to Git by holding the Ctrl key down and right-clicking to choose Team > Share Project:
Please note: You need to be careful with what you check in to Git. Please refer to the section “Can I use an Eclipse IDE with a version control system?” at this link.
Now, click Create to create a new repository. Enter the directory of choice for the project files as shown below:
Note the target location where all the project files will be present as shown below. The project files will no longer be present in the workspace directory.
Click Finish. Note that all the project files now have Git status icon as shown below:
The NO-HEAD label indicates that the Git configuration is not yet complete. The subtle question mark symbol indicates that the projects are yet to be committed.
Step 3: Committing the files
Right-click the project files and select Team > Add to index.
You will observe all the question mark symbols now turn to a “+” symbol. This adds all the files to the staging area as shown below. If there are unstaged changes, it means the files haven’t been added to index yet. If you don’t see the staging area, go to Window > Show view > Other > Git > Git Staging.
Add a commit message to describe the changes. This will serve as a changelog for anyone viewing the files. Click Commit.
Step 4: Creating the online repository (optional if using internal VCS)
Create a public repository in any of the popular web hosting service for Git like Github or Bitbucket. Remember the credentials used to login to these sites. In this case, a repository named “Git_MT_Workspace” has been created.
Step 5: Pushing the files to online repository
Until now all the changes were done in the local repository. It’s time to push these changes to the online repository. Right-click the project files and select Team > Push. In the dialog prompt, add the URL to the repository and the credentials under Authentication. You can choose to check the box Store in secure store to remember the credentials for future use. Follow the onscreen instructions to push the files as illustrated below.
Please note: This is only for the first commit. For subsequent pushes, you can click “Commit and Push” in the “Git Staging” window.
If there is a failure, the possible reasons for failure could be:
- There were changes done online to the files and the current project is not up to date. To solve this, right-click the project files and select Pull. This will download all the latest files onto the project repository. If it says up to date as shown below, then you are in sync with the online repository. Now you can push the changes.
- Access restrictions might be in place for the online repository. Check with the web hosting service to make the access public or for means of authentication in case of a private repository.
If the push was successful, the files appear in the online repository along with the commit message.
To track the changes done to the project, right-click the project files and select Team > Show in history. Selecting each commit gives details on the changes.
To compare the changes, click the “Compare Mode” symbol present in the History window.
Double-click the files to open the compare window.
Lastly, to disable version control, right-click the project files and select Team > Disconnect.