Difference between revisions of "Eclipse & Gitlab Tutorial"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Created page with "This tutorial shows how to use source control software (GIT) from within Eclipse. There are several hosts that can provide GIT services, and [http://gitlab.com Gitlab] appear...")
 
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This tutorial shows how to use source control software (GIT) from within Eclipse.  There are several hosts that can provide GIT services, and [http://gitlab.com Gitlab] appears to be a great one!  In this tutorial, I will show you how to '''CLONE''' my LPC project for the SJ-One board, and you can use the knowledge to work on your own GIT projects.
 
This tutorial shows how to use source control software (GIT) from within Eclipse.  There are several hosts that can provide GIT services, and [http://gitlab.com Gitlab] appears to be a great one!  In this tutorial, I will show you how to '''CLONE''' my LPC project for the SJ-One board, and you can use the knowledge to work on your own GIT projects.
  
== Setup Gitlab Profile ===
+
<BR/>
 +
== Setup Gitlab Profile ==
 +
 
 +
{|
 +
|
 
*  Create yourself a Gitlab profile.
 
*  Create yourself a Gitlab profile.
 
*:  Verify it by clicking on the URL sent by Gitlab.
 
*:  Verify it by clicking on the URL sent by Gitlab.
*  I have setup my GIT project with the following HTTP address:
 
*:  https://gitlab.com/preet/lpc1758_freertos.git
 
*:  Copy the URL above to your clipboard (highlight and Ctrl+C)
 
 
*  At the Gitlab homepage, click on "New Project"
 
*  At the Gitlab homepage, click on "New Project"
*  Click on '''Import existing repository'''
+
* Choose a good project name, such as "lpc1758_teamX"
*:   Paste the URL you copied
+
*  If you want to clone my latest LPC project:
*:  This will create a project and copy my project's source code for you.
+
*: Click on '''Import existing repository''' and copy/paste this: https://gitlab.com/preet/lpc1758_freertos.git
 +
*: If you want to create a parent GIT folder and add one or more LPC projects inside, skip this step.
 +
*  Use '''Private''' for the visibility level so only your team can access the code
 +
*:  You will need to add other Gitlab users later (figure it out yourself!)
 
*  Click on '''Create Project'''
 
*  Click on '''Create Project'''
 +
 +
| [[Image:tutorial_gitlab_newproject.PNG|left|300px]]
 +
|}
 +
 +
<BR/>
  
 
== Clone GIT Repository ==
 
== Clone GIT Repository ==
 
In this section, we will bring-in the Gitlab project in your computer through Eclipse.  Eclipse uses '''TEAM''' as a Git client.
 
In this section, we will bring-in the Gitlab project in your computer through Eclipse.  Eclipse uses '''TEAM''' as a Git client.
  
 +
{|
 +
|
 
*  Copy your Git Project HTTPS URL
 
*  Copy your Git Project HTTPS URL
 
*:  This is not my project's URL, but YOUR project's URL
 
*:  This is not my project's URL, but YOUR project's URL
Line 24: Line 35:
 
*:  Your copied Git repository will auto-fill
 
*:  Your copied Git repository will auto-fill
 
*  Type your username and password
 
*  Type your username and password
 +
*:  Choose "Store in Secure Store"
 
*:  Click Next, and then Next again
 
*:  Click Next, and then Next again
 
*  At this window, you will see '''Finish''', but before you click, use correct destination directory
 
*  At this window, you will see '''Finish''', but before you click, use correct destination directory
 
*:  Choose your "workspace" directory, such as '''SJSU_Dev/projects'''
 
*:  Choose your "workspace" directory, such as '''SJSU_Dev/projects'''
 +
*:  Choose the same project folder, "lpc1758_teamx"
 
*  Click Finish, and wait a few minutes for Eclipse to bring-in the Gitlab project
 
*  Click Finish, and wait a few minutes for Eclipse to bring-in the Gitlab project
 
*:  Your project will show under "Git Repositories" section.
 
*:  Your project will show under "Git Repositories" section.
 +
 +
| [[Image:tutorial_gitlab_eclipse_clone.PNG|left|300px]]
 +
|}
 +
 +
<BR/>
  
 
== Import Gitlab project to Eclipse ==
 
== Import Gitlab project to Eclipse ==
The final step is to '''IMPORT''' the project in Eclipse.  As of now (June 2014), Eclipse has a bug where you cannot use "Import Project" while adding the Git project in the previous section, so we will do this manually.
+
If you cloned my LPC project, the final step is to '''IMPORT''' the project in Eclipse.  As of now (June 2014), Eclipse has a bug where you cannot use "Import Project" while adding the Git project in the previous section, so we will do this manually.
 +
 
 +
Note that if you want to add multiple LPC projects at this GIT repository, just copy and paste the folders of your projects here, and then IMPORT individual projects.  The next section shows you how to COMMIT and PUSH your changes if you have added subfolders of multiple projects at this directory.
  
 
*  In the '''Project Explorer''' section, right click and choose "Import Project"
 
*  In the '''Project Explorer''' section, right click and choose "Import Project"
 
*  Under '''General''', pick '''Existing Projects into Workspace'''
 
*  Under '''General''', pick '''Existing Projects into Workspace'''
 
*  Click '''Next''' and browse the root directory of your project and click '''Finish'''
 
*  Click '''Next''' and browse the root directory of your project and click '''Finish'''
 +
 +
<BR/>
  
 
== Check-in code to Gitlab ==
 
== Check-in code to Gitlab ==
 
After you have a project in Eclipse that is connected to Gitlab, you can now perform changes, and check-in the source code.  Making changes is as easy as editing a file.  Eclipse will inform you which files have changed by using icons next to the files or folders.
 
After you have a project in Eclipse that is connected to Gitlab, you can now perform changes, and check-in the source code.  Making changes is as easy as editing a file.  Eclipse will inform you which files have changed by using icons next to the files or folders.
  
 +
{|
 +
|
 
*  Make any changes
 
*  Make any changes
 
*  Right click on your project and click on '''Team''' --> '''Commit'''
 
*  Right click on your project and click on '''Team''' --> '''Commit'''
Right click on your project, and click on '''Team''' --> '''Push'''
+
*: Type in your Gitlab username and password if needed.
 +
*:  First line should be the heading or title of your commit, ie: "Fix bugxyz"
 +
*:  Next lines can contain details of your changes
 +
*  You can either "Commit" only, or "Commit and Push"
 +
*:  "Commit" will not push your changes, it is like a local commit.
 +
*:  "Commit and push" will push changes to the Gitlab repository.
 +
*  Go to Gitlab and you will see your pushed changes.
 +
| [[Image:tutorial_gitlab_team_eclipse.PNG|left|300px]]
 +
|}
  
 
Other helpful hints:
 
Other helpful hints:
 
*  If others' have checked-in source code, you can go to '''Team''' and '''Pull''' to pull-in their changes
 
*  If others' have checked-in source code, you can go to '''Team''' and '''Pull''' to pull-in their changes
 +
*:  Do this often to continuously integrate other people's code in yours.
 +
*  By browsing to '''Team''' --> '''Synchronize Workspace''', you can see your changes.

Latest revision as of 20:25, 20 June 2014

This tutorial shows how to use source control software (GIT) from within Eclipse. There are several hosts that can provide GIT services, and Gitlab appears to be a great one! In this tutorial, I will show you how to CLONE my LPC project for the SJ-One board, and you can use the knowledge to work on your own GIT projects.


Setup Gitlab Profile

  • Create yourself a Gitlab profile.
    Verify it by clicking on the URL sent by Gitlab.
  • At the Gitlab homepage, click on "New Project"
  • Choose a good project name, such as "lpc1758_teamX"
  • If you want to clone my latest LPC project:
    Click on Import existing repository and copy/paste this: https://gitlab.com/preet/lpc1758_freertos.git
    If you want to create a parent GIT folder and add one or more LPC projects inside, skip this step.
  • Use Private for the visibility level so only your team can access the code
    You will need to add other Gitlab users later (figure it out yourself!)
  • Click on Create Project
Tutorial gitlab newproject.PNG


Clone GIT Repository

In this section, we will bring-in the Gitlab project in your computer through Eclipse. Eclipse uses TEAM as a Git client.

  • Copy your Git Project HTTPS URL
    This is not my project's URL, but YOUR project's URL
  • In Eclipse, make sure that you have the "Git Repositories" view available
    Go to Window --> Show View --> Other
    Click on Git --> Git Repositories
  • Now in the Git window, click on Clone a Git repository
    Your copied Git repository will auto-fill
  • Type your username and password
    Choose "Store in Secure Store"
    Click Next, and then Next again
  • At this window, you will see Finish, but before you click, use correct destination directory
    Choose your "workspace" directory, such as SJSU_Dev/projects
    Choose the same project folder, "lpc1758_teamx"
  • Click Finish, and wait a few minutes for Eclipse to bring-in the Gitlab project
    Your project will show under "Git Repositories" section.
Tutorial gitlab eclipse clone.PNG


Import Gitlab project to Eclipse

If you cloned my LPC project, the final step is to IMPORT the project in Eclipse. As of now (June 2014), Eclipse has a bug where you cannot use "Import Project" while adding the Git project in the previous section, so we will do this manually.

Note that if you want to add multiple LPC projects at this GIT repository, just copy and paste the folders of your projects here, and then IMPORT individual projects. The next section shows you how to COMMIT and PUSH your changes if you have added subfolders of multiple projects at this directory.

  • In the Project Explorer section, right click and choose "Import Project"
  • Under General, pick Existing Projects into Workspace
  • Click Next and browse the root directory of your project and click Finish


Check-in code to Gitlab

After you have a project in Eclipse that is connected to Gitlab, you can now perform changes, and check-in the source code. Making changes is as easy as editing a file. Eclipse will inform you which files have changed by using icons next to the files or folders.

  • Make any changes
  • Right click on your project and click on Team --> Commit
    Type in your Gitlab username and password if needed.
    First line should be the heading or title of your commit, ie: "Fix bugxyz"
    Next lines can contain details of your changes
  • You can either "Commit" only, or "Commit and Push"
    "Commit" will not push your changes, it is like a local commit.
    "Commit and push" will push changes to the Gitlab repository.
  • Go to Gitlab and you will see your pushed changes.
Tutorial gitlab team eclipse.PNG

Other helpful hints:

  • If others' have checked-in source code, you can go to Team and Pull to pull-in their changes
    Do this often to continuously integrate other people's code in yours.
  • By browsing to Team --> Synchronize Workspace, you can see your changes.