FIRST Teach Challenge — An Introduction to GitHub

Kirk Brauer
Sep 8, 2018 · 6 min read

An Introduction to GitHub

One of the challenges of FTC is managing your code and sharing it between all your team members. Many inexperienced teams end up resorting to flash drives, Dropbox, or shared computers to work on code together. What if all this hassle wasn’t necessary?

This is exactly why many experienced teams use a form version management. Not only does it allow your team to share code between computer, but it also allows you to keep a history of all changes ever made to your code in the cloud.

One of the most popular version management tools used today is GitHub. GitHub allows people to backup code, collaborate on projects, and share it with others. This is the primary reason why the official ftc_app code is hosted on GitHub.

GitHub may seem daunting to new teams, but it doesn’t have to be. This tutorial will walk you through the process of setting up GitHub and seamlessly integrating it into your programming workflow.

GitHub is a version management platform that is based on the popular Git software. Git was created in 2005 to help manage the code for Linux. It has grown in popularity every since and is now the most popular version management system.

Projects in Git are called repositories. Repositories can hold any kind of file, but normally they hold code for projects. Each repository is split into different branches. Branches in Git allow you to “branch off” of the latest version so you can test a change before modifying the original code. When the change has been tested, a branch can be merged back into the original source code. The default branch of a repository is called “master”. For this tutorial we will be only using the “master” branch, but in the future you and your team may want to consider using branches to test new code. When you are done with a change in git it is “committed” to a branch. Each “commit” represents a snapshot in the history of your team’s code. GitHub allows you to look back at past commits and see what changes you made. When you have finished committing your changes, they can be pushed to GitHub. Pushing a repository updates the version in the cloud so that other team members can “pull” the changes. If a team member does not yet have your code they can “clone” the repository and start working.

The Git workflow is very advantageous because it allows multiple programmers to work on different parts of the same project without fighting over a single computer.

Setting Up GitHub for Your Team

Ok, now that we have read all the boring stuff, let’s get started using GitHub.

The first step is to create a GitHub account if you don’t already have one.
Click Here To Sign Up

Once you have created your account you can then open Android Studio and begin using Git Version Control.

If you haven’t already clones the https://github.com/ftctechnh/ftc_app repository, you can clone it directly in Android Studio.

Click on the “Check out project from Version Control” button and then select “GitHub”

If you haven’t logged into Android Studio with your GitHub account, you will be prompted to login. Click the “Create API Token” button to enter your username and password.

Click the “Login” button and make sure the Token field is filled.

Then click the “Login” button again to connect your GitHub account.

Once you have logged into GitHub you will be prompted to enter a repository URL to clone. Enter https://github.com/ftctechnh/ftc_app into the URL field and click “…” to select a directory to clone the app to. Normally, the Documents folder is the best place to put your project. Click the “Clone” button to download the ftc_app repository.

Once the project has finished cloning, you will be prompted to checkout the project from version control. Select “Yes” to finish download in the project.

If prompted to import the project make sure that you import the Gradle project from an external model. Click “Next” to continue setting up the project.

Use all the default settings and click “Finish” to open the project in Android Studio.

Once the project has opened, you may be asked to update a plugin before the Gradle sync is finished. Once the sync is finished, you should see a sidebar showing project files.

At this point we are going to create own own GitHub repository inside the one we just cloned from GitHub. This will assure that the changes we make to the TeamCode package are the only files we save. This will also allow us to reclone the ftc_app repository to update it without messing up our own version management.

To create the sub repository, click on the “VCS” dropdown menu and select “Import into Version Control” and “Create Git Repository…”.

When asked to select a location for this repository make sure to select the TeamCode folder inside the ftc_app project.

This seperate TeamCode repository will be where your team will store all of their code and what will be synced using GitHub.

Once the repository is created, you must add a .gitignore file to tell GitHub not to save temporary files generated by Android Studio.

To create the file, right click on the TeamCode folder and select “New > File” and name the file “.gitignore”. Next, paste the contents of the file above into the file.

Once you have added any code to your TeamCode folder, you can then push the repository to GitHub. First, click the “Commit” button in the upper right corner of Android Studio. You will then be prompted to select files to commit. Tick all the checkboxes to make sure that everything will be synced. Then, add a commit message telling the world of your new great achievement.

Once the changes have been committed, you can then sync the project with GitHub by selecting. “VCS > Import into Version Control> Share Project on GitHub” Before doing this step make sure that you are working inside the TeamCode folder, otherwise it will not work correctly.

Next, think of a creative name for your repository and click “Share”.

You can then go to github.com and see your project in all it’s glory!

The next time you wish to make a change, you can commit it and then click the “Push” button (next to the “Commit” button) to push your changes to GitHub.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade