Version control

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Posts: 10
Joined: Sun Aug 26, 2018 6:04 pm

Version control

Post by Batman » Thu Aug 01, 2019 5:22 pm

I have a general question about the workflow for working with the pyboard: how do you go about version control?

I am working on a project which involves multiple files. I want to use version control to keep track of the project. However, I can't find a good way of doing this. Here is what I tried:

Pycharm and the micropython plugin
Advantages: You get the power of the Pycharm editor. A local copy of the code lives on my disk and is flashed to the board. I can use git to keep track of changes to the local code.

Disadvantages: The plugin seems buggy. The main problem I experienced is that I could not find a way to exclude directories/files from flashing to the board. There is supposed to be a way to do so but, at least on my installation, this feature is broken and it's an open issue: ... /issues/46

Advantages: This is a good lightweight editor that allows editing the code directly on the board. The REPL feature is neat and very convenient while debugging.

Disadvantages: If I edit the code directly on the board, I can not do version control. One thing I tried for a while is to manually copy my code from the board to my disk. This allows for version control. But it is tedious and prone to error.

So my question is whether someone has found a good workflow for more complex project? One option I thought about would be for a process to monitor the pyboard and sync the contents to the board to my hard drive. I could then run git to do version control on the hard drive. I haven't been successful in setting this up.

Any suggestions would be great. I am on linux.

User avatar
Posts: 2052
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Version control

Post by jimmo » Thu Aug 01, 2019 9:59 pm

I use an editor that doesn't have any micropython support, so it's up to me to manage the files on the device. TBH a large amount of the time I still use the USB drive to copy changed file(s), wait for the red light to go out, Ctrl-D in the terminal to soft reset.

When I'm working on something single-file (or if it's using libraries on the board that are not changing), then I use

For the most part recently I'm using ` -f` to do filesystem stuff, but having to disconnect the REPL is a bit frustrating. rshell provides the same functionality (and more).

rshell has an rsync command, which is great for keeping your local and on-device directory structures in sync.

Overall it's fairly essential that the master copy of the code is on your PC. Not just so you can version control, but because of the chance of corruption on the device.

User avatar
Posts: 4787
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: Version control

Post by pythoncoder » Fri Aug 02, 2019 6:25 am

I use Kate as an editor on the PC with Git for version control and rshell for copying the files to the target. Git has a steep learning curve but it's an essential skill if you want to make contributions to MicroPython or to host your own code on GitHub. Kate and rshell are superb tools in my opinion. I use rshell exclusively for managing the filesystem on the device - in fact I disable USB MSC mode on devices which support it as it can cause filesystem corruption on the target.

All program files are stored on a NAS box which is backed up.
Peter Hinch

User avatar
Posts: 2272
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Version control

Post by Roberthh » Fri Aug 02, 2019 6:46 am

Like @jimmo and @pythoncoder I keep the source files on the PC, using an editor there. At the moment, it is VSC, because I can use the same editor on various platforms. The Version control tool is git, and VSC has good support for it.
The tool for copying files to the device vary with the board. If the board has a network interface (WiFi or LAN), I use Filezilla, otherwise or recently I have a few python tools which I embed in the firmware as frozen bytecode:
- a small editor for on-board editing - small fixes and quick hacks.
- a small set of unix-like commands like ls, rm, mkdir, cat,
- a ftp server for devices with network and not ftp server in their firmware (all except WiPy1).

Post Reply