In my daily work at CTGlobal we are all working a lot with PowerShell and therefor we have a big need to share code between each other and also having some version control in place when we are making changes. So for the last few months I has been playing a lot around with Visual Studio Code and Git repositories in Visual Studio Online to solve this.
A free Visual Studio Online Account and a project to work in
To create a new code repository in VSTS go to the project you want the repository to reside in and select the Code tab. Click the repository drop down and click New repository. A box appears, enter the name for the new repository and select Git type. You now have a new repository.
To clone the repository to your local computer and work with the code click Clone in the right corner and copy the URL.
Open Visual Studio Code, press F1 to open the command palette and write Git: Clone
You will then be asked to enter the URL you just copied, and then the parent path where the local copy if the repository will be placed.
The repository will then be cloned to your local computer and you can start to add files to it. When you have added some files or done any changes and you want to save it to the repository you have to commit it. You commit changes by going to the Source Control tab on the left in Visual Studio Code, review the changes and click Commit.
The changes are then committed to the local copy of the repository. To sync the changes back into Visual Studio Online press F1 to open the command palette again and write Git: Sync and press enter, the changes is now pushed back to master repository and your code is in control.
Happy source controlling!
One thought on “Visual Studio Online + VSCode = Easy PowerShell Source Control”
[…] repositories, you can use a Git client like Visual Studio Code to push the files into the it. See Visual Studio Online + VSCode = Easy PowerShell Source Control for how […]