Let's Make Robots!

Using git to keep track of your µC programs


Have you ever programmed a microcontroller and after just a little change you made, the code - that was running completely fine last week - is not working anymore?

Well I think we all have been stuck in this situation already. It is very hard to keep track of all the changes made to the program code, especially if the project includes more than one source file, e.g. when programming a robot.

There is a way of getting around that, it's called version control. The version control system git is a big composition of many small and fast programs which makes it very powerful and flexible. It gives you the possibility to work on a code project with many people at once. You can track every commit that was made to the program so if you find you have messed something up you can go back in the commit history and reset the git repository to the most recent functional state. Pretty nice huh? The best thing is that git can do all that for you nearly fully automatic!

Ok so... how do I set a git repository up?

Setting up a git repository is not that hard once you have installed git. On most Linux distributons git can be installed from the software repositories and there are packages for Windows and Mac available. Though git originally is a command line program there are easy to use GUIs available if you're a little scared by that. Setting up git:

Where the last bits are only relevant if you want to use GitHub (which I really like!). Here you can find loads of information on setting up repositories:

GitHub

You can use git just as a local version control system because that is how it was designed but imagine you want to develop code for the same project with more than one computer. Now it becomes very tricky to keep track which version of the code is on which computer.

You can get around this by setting up an online repository at GitHub. You can upload the changes you made to the project to this online repository and then when working on another computer you can fetch the made changes and merge the changes with the local version on that computer.

Now there is now more hassle with different versions on each computer when developing bigger code projects! Check it out it really makes life easier!

P.S.: I am using git to track changes made to the code of my robots.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Ha, I use gitHub at work all the time, but have never thought about using it for my own projects. I think I'll give it a try next time I start something new. Thanks for the tip. 

Nice work Torrentula!! Thanks for posting this!

No problem :)