Mint Source

Code snippets, tips, and tricks…

Archive for the ‘Git’ Category

Using Git to Sync Scripts Between PC and Pi

leave a comment »

I run my Raspberry Pi headless most of the time; Connecting to it from my PC via SSH.

Nano is a fine text editor, but I’m more comfortable in Visual Studio on my PC. I could work in Visual Studio on the PC then copy and paste into Nano on the Pi, but that’s not ideal. It’s also easy to get out of sync and loss track of what’s where.

To improve my situation I set up a Git repository in Visual Studio Team Services. To be able to access it from the Pi it’s necessary to setup Alternate Credentials.

EDIT: VSTS now supports

I can now work on my code in Visual Studio, version control it with Git and pull changes straight on to my Raspberry Pi.

First set up a Git Team Project in Visual Studio Team Service.

Then, from the Pi shell, first clone the remote repository:

git clone https://{youraccount}{yourteamproject}

Then simply pull changes to the Pi when necessary:

git pull

Your credentials will be required every time you interact with the remote repository, but you can have Git store your credentials so you only need to enter them once:

git config credential.helper store

Warning: Your password will be stored in a file in plain text. Replace ‘store’ with ‘cache’ if you’d prefer your credentials were stored in memory instead, and not persisted at all.

 UPDATE: VSTS now supports SSH connections, so there’s no need for alternative credentials or credential caching:

First, create an SSH key on the Raspberry Pi. (You could also use an existing key)

ssh-keygen -t rsa -b 4096 -C ""

Press ‘Enter’ when prompted to accept the default file location.

Next, add the contents of ~/.ssh/ to Visual Studio Team Services:


Finally, you can clone your git repo via SSH:

git clone ssh://{you}@{youraccount}{yourteamproject}


Written by Andy Lamb

January 9, 2016 at 01:28

Posted in Git, Raspberry Pi