While presenting on Vester at the past few events, I’ve been asked about my usage of Dropbox and Git for providing source control on my various devices. In this post, I’ll explain my process and tools used to write PowerShell code on my various devices, including my sync strategies.
I use three different devices for my daily work: a Surface Book, a Surface Pro 3, and my whitebox desktop build at home. Each of these are running either Windows 8.1 or Windows 10. This means that they all have the PowerShell ISE (Integrated Scripting Environment) installed by default, along with PowerShell version 4 or better.
I’ve deployed WMF 5.0 into my Windows 8.1 device (the Surface Pro 3), which granted me access to PowerShell 5.0. The Windows 10 anniversary update included PowerShell 5.1 by default; no activity was required.
In order to sync code across each device, I use Dropbox. This is a throwback to my Windows 7 days when there was no integration like OneDrive, which provides profile and data sync across devices running more recent copies of Windows, built natively into the platform. It also allows me to use any variant of Windows without having to rely on OneDrive specifically. I also just kind of like Dropbox. Perhaps some day I’ll switch over to it.
Each device has Dropbox installed into the same path to make global scripting simple. I use C:\Dropbox (the root of the system drive). From there, I have a
Code folder that contains a number of different projects I’m working with.
In a nutshell, this means that all of the projects I am working on are sync’ed across all devices without having to worry about which distributed version control system (DVCS) I’m using within the project itself. If I start writing some code on the plane using my Surface Book, that code will sync back to my Surface Pro 3 and my desktop at home without having to think about it. It also means that I can store some test configuration data that I never want uploaded into version control by leveraging the
Distributed Version Control
If we peer inside of a project folder, we’ll find that there’s some sort of version control system in play. For the two examples shown above, Rubrik and Vester, I’m using Git along with GitHub. This is fairly easy to see; by opening the Vester folder, you can see the
.git folder. This is where Git stashes all of its data for the various versions and branches of code.
Because of this, the use of Dropbox means that all Git data is sync’ed across devices, too. If we peer into the
.git folder, we can see what it contains.
I like to think of this as having a distributed compute and storage layer across my Windows devices, with Git being my toolset for making changes that ultimately get sent upstream to GitHub, Bitbucket, GitLab, or others.
OneDrive Profile Sync
The single area where I do take advantage of OneDrive is for my PowerShell profile. This is saved into a file named
profile.ps1 and is located in OneDrive under
Documents\WindowsPowerShell. For details on my profile, check out this post.
There you have it. A relatively simple configuration, right? As an added bonus, using Dropbox means that I never have to worry about backing up my changes to the code: any loss of data or accidental deletes can be reverted. It also means that I can share out code using a Dropbox link if I don’t want to publish it to a remote Git repository (such as GitHub).
I’m assuming there are more robust, exciting, and perhaps “better” ways to do this – but this method works for me and takes practically no effort to run. Enjoy! 🙂