GitHub is a great way to keep a project up to date for multiple people across many computers. When a project is pushed or pulled it is either uploaded to GitHub or downloaded from GitHub. Unlike a normal upload or download of a file, these pushes and pulls will only contain information about individuals lines of code that were added, changed or removed. This means that it is possible for multiple people to be making changes to a project at the same time and to have those changed merged later on.
When using a project that is connected to GitHub, it is important that you “pull” updates from the GitHub repository when you start working on a change, and that you pull again before pushing to the repository. It is also suggested that you push small incremental changes regularly rather than only pushing after a large number of changes have been made to the program. For example, if you work on the drivetrain and the shooter, make sure to push after working on each task rather than grouping tasks to a single push. This should be done with one exception; you should only push if you feel that the robot can still function if you were to stop writing code at that moment. A push should not leave the robot program in an nonfunctional state.
Below is an explanation of how to use GitHub and Eclipse. If you are starting a project, make sure to put the project on GitHub using the instructions in Creating a New Github Project. If the project exists on GitHub but does not yet exist on the computer you are working on, make sure to follow the instructions in Adding a Project to Eclipse that Has Already Been Put on GitHub. Once a project is on your computer and GitHub, and further changes made to it will require you to pull and push. Instructions for doing both of these can be found in Updating Eclipse with the Latest Changes to a GitHub Repository and Adding Changes Made in Eclipse to GitHub respectively.
Creating a New GitHub Project
Creating the Repository on GitHub
1. Go to github.com and sign in
2. Click on the + on the right of the top bar
3. Click New Repository
4. Under Owner, open the dropdown (which should default to your GitHub account) and select Team484
5. Where it says repository name, enter the name of the project used in eclipse
6. MAKE SURE that “Initialize this repository with a README” is unchecked and that None is selected for .gitignore and a license
7. Click Create Repository
8. On the following screen, copy the URL mentioned under Quick Setup. It should start with https://github.com/team484/ followed by the project name and ending it .git
Adding the Eclipse Project to GitHub
1. Right click on the project of interest in the Project Explorer in Eclipse
2. In the drop down select Team and click Share Project…
3. On the menu that follows, click Create
4. The default directory should be the home directory with /git added to the end. After /git add another slash followed by the project name (For example: /Users/kevin/git/MyRobotProject)
5. Click Finish followed by Finish
6. Right click on the project, select Team, followed by Commit
7. This should bring focus to a git staging window
8. In the window, drag all the files from Unstaged Changes to Staged Changes. (Select one of the files, press control + A / command + A on your keyboard and then drag all files at once to staged changes.
9. Type a commit message in the 3rd box. It should be written in present tense and briefly mention what is done in the project so far
10. In the boxes Author and Committer replace what is there with your GitHub username and email address (Example: myUsername <myEmail@site.com>)
11. Press Commit and Push… (Do not simply press Commit)
12. On the screen that follows, paste the URL from GitHub into the URI box in the location section
13. In authentication, enter your email and password for GitHub. If this is a person computer, you can save your password using the Secure Store
14. Click Next, then Next, then Finish
15. Your project should now be uploaded to the team484 GitHub page. Check to make sure.
Adding a Project to Eclipse that Has Already Been Put on GitHub
1. Go to the project’s GitHub page
2. Click on the green button that says Clone or Download and copy the URL that it contains
3. Go to Eclipse
4. Click File then Import
5. In the Git folder, click Projects from Git
6. Select Clone URI and click Next
7. Paste the URL into the URI field and enter your credentials.
8. Click Next numerous times and then click Finish
9. The project has now been added to Eclipse
Updating Eclipse with the Latest Changes to a GitHub Repository (Pull)
1. Right click on the project
2. Select Team and click Pull (The one without the …)
Adding Changes Made in Eclipse to GitHub (Push)
1. Right click on the project
2. select Team, followed by Commit
3. This should bring focus to a git staging window
4. In the window, drag all the files from Unstaged Changes to Staged Changes. (Select one of the files, press control + A / command + A on your keyboard and then drag all files at once to staged changes.
5. Type a commit message in the 3rd box. It should be written in present tense and briefly mention what has been changed/added/removed in the project
6. In the boxes Author and Committer replace what is there with your GitHub username and email address (Example: myUsername <myEmail@site.com>)
7. Press Commit and Push… (Do not simply press Commit)
8. If needed, it will ask you for authentication, enter your GitHub email and password if this happens
9. Your project should now be updated on GitHub. Check to make sure.