![]() |
Why you should care about version control, and why I suggest git
Hi everyone!
As we roll towards this year's competition, I wanted to suggest something for the volunteers who will be working with control systems programmers (and the teams who have control systems programmers, and the team members who are control systems programmers... Hello, my fellow code-slingers!). If you're already familiar with version control, feel free to skip all of this. Executive summary:
Before I dive any deeper into this, I should direct you to the excellent document put together last year by Austin Wright (team 498 alumnus). Document hosted on Google Docs. He already said many things about git that I was going to say, and several of them better; consider this message a refresher on the ideas and an update on some new developments in version control. Why use version control? One of the big things I learned about in college that I wish I had known in high school was version control. I remember that when I was working on my team's robot control code, we would sometimes need to make very quick, experimental changes under a tight deadline. We ended up with dozens of little folders labeled "control system_1", "control system_2", etc. It was a disorganized mess; code could get saved in the wrong folder, they would get lost (put on the wrong floppy disk), etc. It's a pattern I've seen repeated with many teams over the years. Version control software is basically a system to manage the problem of code changing over time. Instead of backing up versions of the code to other folders, you register files with the version control program (VC) and when you want to make a "backup"[1] (checkpoint), just tell the VC to make it. The VC will keep the checkpoint and a log of what was changed, and if you ever need to pull up a backup and use it, you can just say "Give me the code from Monday" or "Give me version 2". There's always a "right way" to do save-this-version-so-I-can-get-back-to-it-later, and nothing can ever get lost. Checkpointing is the main thing a VC does, but the metaphor goes beyond recording the past. VC software also lets you make "branches," which are like specialized versions of your code to test experimental ideas or for one programmer to make detailed, finicky changes without interfering with the rest of the team. A successful branch can be merged back into the project (becoming part of the regular code), or kept around as a separate part for special purposes. For example, a team might have an automation feature they don't fully trust; they can keep it on a branch, and if it turns out to not be useful they can just switch back to the regular behavior by moving from the branch to the main code history without losing anything. There are several VC programs available, the most popular probably being subversion (http://subversion.tigris.org/). I use subversion (svn) regularly, and it's a great tool. However, it requires the computer to be able to access a subversion server, which may not always be possible for teams that lack a reliable internet connection. Another VC that may serve the needs of FIRST teams better is called git (http://git-scm.com/). Git acts as a more decentralized VC; with a VC like subversion, the server maintains the "repository" (the binary-soup of files that make up the entire history of the project and allow you to pull up any checkpoint that has been made). If you can't access the repository, you can't make a new checkpoint or move to another checkpoint. With git, each individual machine using a project keeps a copy of the project's whole history, so each machine is both a client and a server. Teams can use a centralized server, but they can also do something more "sloppy" like keep the repository on a few loosely-affiliated laptops or desktop machines, synchronizing their histories when it is convenient to do so. Tips on using git (and version control in general) Commit early, commit often One significant difference between version control and keeping a loose bag of backup folders is that is is much cheaper to make a checkpoint (also known as a "commit") than to copy a project. Much cheaper, both in space used and time used. I try to commit every time I add a new feature, no matter how few files or lines I changed. That makes it easier to roll tiny pieces of the project back if I made a mistake. Branches are cheap (in git) The way git is designed, branching (and merging branches back into the main code body) is very easy; it's assumed every programmer has his or her own personal branch. So make branches whenever you want to experiment with an idea that is in the least bit "risky." You can always back up if you find it's not worth the time to chase the idea, and you won't lose the work you put into it already. It's not just for robot code Does your team do its own promotional materials? Version-control the flyers and announcements. Does the team keep a team contact sheet or roster? Version-control it so you can remember who was on the team in 2009 when you're doing your five-year anniversary montage in 2014. Does the team have a website? Most definitely version-control that. You can have as many or as few repositories as you want; any file that changes over time could likely benefit from being version-controlled. It's not actually a backup This is an important point to keep in mind: version control isn't quite the same thing as backing up unless a copy of your repository lives on another computer (such as the GitHub service; see GitHub in "Tools to use with git," below). Version control basically adds a rewindable history to each file in the form of the repository; while it can be used to fix a file that is damaged, damage to the repository itself will ruin the history. You'll still need to be able to restore the entire repository from an off-computer backup if you accidentally set your machine on fire[2]. Tools to use with git documentation Most of what I know about using git came from one document: the "Pro Git" book (http://progit.org/book/). This is fairly comprehensive and covers more-or-less everything important in a pretty straightforward manner. user interface By default, the user interface to git is command-line only: you tell git what to do by invoking commands like "git init", "git add", and "git push". But there are a couple of great GUI tools to simplify that process.
hosting Even though git works perfectly fine without an external server, a centralized server can be useful for collaboration. If a team wishes to, they can certainly set up a machine owned by them to be a central server; however, there is an option for creating a host on the web that can be accessed anywhere in the world with an internet connection.
Conclusion
----- Notes ----- [1] Checkpoints aren't exactly like backups; see the "it's not actually a backup" tip [2] That happened to me once. If you turn on a computer and it starts clicking instead of booting up, try not to be surprised when after turning it off and on again it lets out the magic smoke. |
Re: Why you should care about version control, and why I suggest git
Nice little post. I played with Git for the first time a few weeks ago and found the same documentation resource as you, which was quite a help. Git is a very nice system versus SVN which I had used a few years ago. It is something that programmers should look at.
My team was thinking about using Git for the next years as it would go along with Java or C++ quite nicely. We were thinking about having the main programming desktop contain the Git server where upon all the programmers would download the code into their laptops and make edits and so forth. If anyone wanted to bring it home, all they would have to do is take their laptop home, do the same edits and commits, and bring it back the next day. The main server would retain all their edits and separate commits. Now to me, that is just cool. -Tanner |
Re: Why you should care about version control, and why I suggest git
The software's name is also a mildlly derogatory term for someone <insert undesired behavior here> particularly used in the UK. Kinda like a Nob in Canada.
|
Re: Why you should care about version control, and why I suggest git
Strongly agree with this post--team's that havent looked much into version control should definitely read this.. :)
I've liked git mostly for its amazing automerging system--yes Hg and SVN have merge tools and auto stuff, but git is by far the best. |
Re: Why you should care about version control, and why I suggest git
Quote:
In general I think git has no advantage over Mercurial, the only difference being Mercurial is easier to use (Also, Mercurial is more space efficient than uncompressed git repo's, and compressing takes FOREVER). |
Re: Why you should care about version control, and why I suggest git
yeah, our team has been using some sort of VC at least ever since I've been on the team. 2 years ago, we went ahead and manually ran some sort of VC, which works well, depending on the programming team. Last year, we went with SVN, because it is whats most familiar with our programming team(both of us are heavy on open source development). What you use for VC should be what you programming team is most comfortable with. VC is a must though. It ends up being used quite often.
|
Re: Why you should care about version control, and why I suggest git
Quote:
Though I agree Mercurial is my favorite. |
Re: Why you should care about version control, and why I suggest git
I use Tortoise SVN for revision control and have recently giving a presentation on the topic
http://decibel.ni.com/content/docs/DOC-7811 One note you DON'T need an internet connection to use TortiseSVN. I put my repositories on my local hard drive. |
Re: Why you should care about version control, and why I suggest git
FYI none of these version control systems need an internet connection. That just allows you to stay synchronized with your team.
I should point out that NI has good merge and diff tools for labview if you are using that. |
Re: Why you should care about version control, and why I suggest git
Quote:
|
Re: Why you should care about version control, and why I suggest git
Quote:
|
Re: Why you should care about version control, and why I suggest git
I really love everything that was said here. This is certainly a thread I'll shoot to new programming students, and other people of interest.
Quote:
Some might think that they would be embarrassed to show their code(whether labview or C++) due to lack comments, cleanliness, and what have you, but I think if we can keep it all on a professional(the feed back that is) level it can be extremely insightful. |
Re: Why you should care about version control, and why I suggest git
Even if the SCC stuff is included this year has anyone looked for any free products that will interface with it. The list that you can find on the NI site Here doesn't seem to have anything that is free. Most are limited trials or only work for a few users. At least that was what i have came accross so far from looking into it.
|
Re: Why you should care about version control, and why I suggest git
That list is for tools that are integrated. Any SCC tools that can handle binary files will work with LV, but you will then use their command line or GUI to do check-in and check-out. These tools have wrappers already built into the LV IDE so that you start to edit, confirm a checkout, and continue editing.
Depending on the project, I've used both, and while integrated is nice, sometime it is useful to learn the tool's API for advanced stuff anyhow. If not using the integrated tool, a diff would consist of getting both revisions on disk and using the LV Compare tool on those files. Greg McKaskle |
Re: Why you should care about version control, and why I suggest git
Greg,
Based on your experience with LV, the version we will be getting, and the fact that most teams have little experience with SCC, what would you suggest we use? |
Re: Why you should care about version control, and why I suggest git
I downloaded the tortoiseGIT stuff the other day as I had no experience with it. XMas has prevented me from doing anything except install it.
So, I haven't formed an opinion yet as to what might be easiest for teams to pickup and use effectively. I'll try to get back in the next few days with an opinion. Anyone else, feel free to throw in your answer. Greg McKaskle |
Re: Why you should care about version control, and why I suggest git
I would like to report that I have had success using Mercurial with LabVIEW. With some python hackery (is there any other way? :) ) I got LabView Compare to work with Mercurial's automatic diff tools. I think Mercurial + TortoiseHg + bitbucket is an excellent and simple setup for FRC teams.
|
Re: Why you should care about version control, and why I suggest git
Quote:
|
Re: Why you should care about version control, and why I suggest git
Quote:
|
Re: Why you should care about version control, and why I suggest git
Quote:
|
Re: Why you should care about version control, and why I suggest git
Thanks for the information. I have been wanting to set up some sort of version control for my team. I have been having trouble getting it set up, though. I have installed git and tortoisegit. I have a couple of questions.
1. Does anyone know how to use git with Windriver workbench? a) How do you tell windriver not to try to compile everything in the .git folder? b) What is the workflow? I assume you can't access git from within workbench. So you have to open up the windriver workspace in explorer, use the tortoisegit commands from there, return to windriver workbench, do your editing, then return to explorer to commit the changes? 2. How do you allow your whole team to work on a project hosted at github? I figured out how I can access it using a SSH key, but I'm not sure how other programmers can also share the same project. Thanks! - Kevin |
Re: Why you should care about version control, and why I suggest git
Our team is using SubVersion (SVN) this year, and so far like the tight integration to WindRiver Workbench. We load TortiseSVN too, but don’t use it much anymore because the “team” tools in Workbench can checkout, branch, tag, merge, commit the code without leaving the development environment. SVN works well for us, but we do have high speed Internet service at the build site to stay connected to the repository. If we didn’t we could just put up a local SVN server, but that could lead to conflicts as the team does some of the coding from home.
I like the comments around git, and will take a look at it for next year. How do you use it with Workbench? |
Re: Why you should care about version control, and why I suggest git
I found the "add collaborators" button in github, but I still can't figure out how to stop WindRiver from trying to compile all the stuff in the .git folder. Does anyone know how to do that?
Thanks, - Kevin |
Re: Why you should care about version control, and why I suggest git
Quote:
- Kevin |
| All times are GMT -5. The time now is 16:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi