Preface - Target
This guide is for anyone who would like to use the version control system git with RobotC in an FTC environment. This could also be used for CAD files, but it is not recommended, since CAD files are binary data which is not handled well with traditional version control systems. The same argument applies for LabVIEW files.
Git is a free software version control system initially developed by Linus Torvalds to help him create his more well-known project, Linux. Git attempts to solve many of the problems posed by earlier version control systems, and in the author's opinion, succeeds at this.
When reading this guide, after any command which is to be typed into the command line, it is implied that you press enter. There are essentially no exceptions to this, and when there are, I will point it out.
Step 0: Learn how it works
Version control is the concept of storing different versions of a piece of software as it is developed, so that if a bug is discovered in a piece of code, its origin can be identified, and the previous version of the code can be looked at to see how the bug could have developed. The other main feature of version control software is that it allows multiple developers to work on one code base, and receive the code changes that others make. This is the feature that will be most used by an FTC team (since the first feature is more useful in projects with many, many coders).
Git works differently than the version control systems the precede it. Git is distributed, fast, and lends itself to a certain workflow. Let's analyze these points:
Distributed
This means that there is no central server to contain your code and its history. The bonus of this is that, say, if the central server is hit with a Tsunami, Earthquake, Alien attack, or other phenomenon that destroys your data, you still have your code, since there isn't any true central server. With Git, you can set up a repository that you treat like a central repository, but that is something that you do yourself, not something imposed by Git. Every repository in Git contains the entire history of the codebase.
Fast
Since your computer doesn't talk to a server when doing a git operation, it permits the Git program to be very fast. This doesn't really apply to FTC, since the codebase is only a couple hundred lines typically, but Git is used to manage massive pieces of software, and it does so quickly.
Lends Itself to a Certain Workflow
In version control, there is an operation called a merge. A merge is when two code bases are folded together to create one code base with the features of both (normally, these code bases come from the same source earlier in time). In other version control softwares, this is a time-consuming, confusing, and difficult operation, rarely performed. In Git, merging is one of the most common operations performed, second to its inverse, forking. This lends itself to a workflow where programmers work on their code, and someone else merges that into the master code base. The Git workflow as it applies to FTC will be more deeply explained below.
Step 1: Decide on a Hosting Service
This is an important first step to make. Since Git is distributed, a hosting service is not required; however, it makes it easier to develop code, since everyone can easily merge the hosted version into their version, a process which in Git is called "pulling". There are two good git hosting services which I know of, which are Github and Google Code. Also, you can use a network server, if your school has one.
Github
Github is a website founded in 2008, which exclusively hosts git repositories. Their website is highly polished (with a hint of comedy), and the Github team has expanded into creating a desktop client for Github, along with Android and iOS apps for their platform. Their influence in the Git world is strong, and a feature of their platform, the pull request, seems like a part of Git itself.
Google Code
Google Code is a code hosting service provided by the software giant Google. Google Code supports multiple code access methods, one of which is Git. The potential downside of using Google Code is that Google can only provide freely available hosting space; using Google Code as a host means that anyone can read your code, and its history.
Local Hosting
If your school or organization provides a directory which all of your team members' computers can access, then you can place a repository there. Members of the team can push code to there, and other members can pull from that repository. This avoids hosting options entirely, and is the preferred option.
None of these hosting options are more difficult to use than the others, they are just different.
Step 2: Obtain Git
Git can be obtained from this location. Git is typically used from a command line interface. Don't let this scare you; it isn't harder than a graphical interface, it just means that you have to know what to type, instead of what to click. If you chose Github as your hosting service, you can use the Github for Windows program, which is rather nice and convenient to use, but this guide will not cover its use.
After you download Git, run its installer. Click through the prompts, until you reach this screen:
You want to pick "Run Git and included Unix tools from the Windows Command Prompt". Don't mind the warning, unless these are tools that you commonly use. Next, you will be given a choice of line endings, which doesn't really apply to a RobotC programmer. Choose the first option, which is selected by default:
Git now installs. Click "Finish" as soon as it finishes. Congratulations, you now have Git! Now you must configure git so that it knows who you are. To do that, run the following commands:
These settings don't control anything, but they will be tagged along with your commits. If you use an online hosting service, the email address should be the email address should be the one you specify when creating an account there. Remember, if you use an online hosting service, the name you specify will be publicly visible.Code:git config --global user.email "deankamen@gmail.com" git config --global user.name "Dean Kamen"
To confirm that git works, open a command line, and type the following:
And then press enter.Code:git version
The result should look like this:
If it doesn't, you have a problem. Start a thread with the problem, and I'll help you get it fixed.
Step 3: Create a Git Repository
Doing this creates the git folder that contains the information that git uses to do its magic. First, change into the directory that houses your code with the "cd" command:
Which should result in something like this:Code:cd "C:\Users\Path\to\your\code\base"
![]()
















