Why you should be using Version Control. Matt Krass Electrical/Software Engineer mattkrass@gmail.com...

Preview:

Citation preview

Why you should be using Version Control.

Matt KrassElectrical/Software Engineer

mattkrass@gmail.comNovember 22, 2014

Who am I?

• FRC Student from 2002 to 2006, FRC263 Mentor from 2010 to 2013, now I’m a free agent!

• Control System Advisor at the SBPLI regional• BS Computer Engineering• 3 years as an embedded software/digital

systems designer• Now I write financial software used by the

world’s leaders in commodity trading

Overview

• What is version control?• Different types of version control• Pros and cons of using version control

– Examples of version control usage– Backups– Industry experience!

• Different types of version control – Centralized, server based (CVS, Subversion)– Distributed (Git)

• Demo of Git• Questions and Answers

What is version control?

• Maintains a record of all the different versions of files under control

• Tracks specific changes to each version• Records a log with each version describing the

changes• Allows specific changes, or entire change sets

to be undone• Facilitates collaborative programming efforts

What is version control?

Example: Team 358 has a working vision tracking system and can score points by shooting a ball in to a goal during autonomous mode. Matt notices that the robot is shooting a bit left, so he tweaks the program to add a small offset to the tracking so it shoots more centered. He is confident, and doesn’t write down the old setting.

What is version control?

Example (cont’d):The next match, the robot misses the goal by several inches to the right! Matt now has to scramble to remember what number was working while his team stands behind him giving him menacing looks!

What is version control?

Example (cont’d):If Matt was using Version Control it would be a simple matter to restore the code to the exact version he had before he decided to “improve” it.

How many times have you said “It worked yesterday, can we go back to that?”

Common concepts

• Revision – some indicator of a specific version of code.

• Branch – a version of the code split off from a previous version and becoming a separate instance, great for testing!

• Tag – a label referring to a specific version of a specific branch

• Commit – the act of saving a specific set of changes in to the version control system, this is when it gets a revision and becomes controlled.

Typical workflow

• Starting from a known codebase, that is already committed, changes are made to fix something or add functionality

• Changes are tested and iterated until the desired result is achieved, bag day sneaks up, or the idea is scrapped.

• If you want to keep the changes, you commit them and get a new revision of the code

• If you decide you want to undo the changes, you simply revert to the original version as recorded by the version control system.

Still with me?

Common types of version control

Centralized, server based (Subversion)

The repository is stored on a single network connected computer, there is only one master repository and programmers need to be able to connect to it to commit changes and view change log.

Common types of version controlPros and Cons of a centralized version control system

Pros Cons

There is an authoritative master record Single point of failureAll committed versions of the code are in

one spot Generally more complicated to set up

Simpler revision scheme Unavailable at competition typically

Less friendly to collaboration

Not recommended for FRC!

Common types of version control

Distributed (Git)

The repository is stored on your computer, there is no central repository and all versions and the change logs are stored locally. The repository can be cloned freely and pushed to a server for storage and sharing.

Common types of version controlPros and Cons of a distributed version control system

Pros Cons

Typically much simpler set up No single “master” recordRepository is always available for

commits, rollbacks and history Single point of data loss failure!

Allows repository to be effortlessly cloned for other’s to work on, and supports bringing changes back in to original

repository if desired. More complicated revision scheme

Cloning repositories makes it very easy to make backups (You do keep backups don’t

you?)

Recommended for FRC!

Bonus for Git users!

GitHub, a popular website for collaboration and sharing of Git-controlled projects, is offering a free “Silver” organization plan to FRC teams, this allows you a place to store your code on their servers privately, or publically if you choose, along with a number of useful tools. Details here: https://github.com/pricing

Request it here: https://education.github.com

So what’s the big deal?

• Version control provides a number of benefits at really no cost.

• Subversion and Git are both freely available solutions that are widely supported, and both easy to set up and use as well.

• For students it is great industry experience!

Benefits

• You can always return your code to a known working state when trying to track down problems.

• If using a server based solution, or “pushing” a distributed solution off to another computer, you’re gaining automatically labeled and date stamped backups

• Robot design is iterative, especially software design, it’s easy to get overwhelmed with how many changes you’ve made without a way to track them!

• If you want to test something out, or let someone new try their hand at programming, you can do so safely knowing you can always go back.

Git Demo

I put this slide in to remind me to pause here and show you a quick demo of how to use Git to

track and revert a set of changes.

But wait, there’s more!

Version control isn’t just for code! You can use it on CAD drawings, budget spreadsheets, t-shirt designs, just about anything you create on a computer can be used with version control systems.

Questions?

Feel free to email me with any questions you have regarding version control systems:

Matt Krassmattkrass@gmail.com

Recommended