Manage your scripts using Git for Windows and GitHub, a version control system.
In this article, I’ll show you how to quickly install Git on Windows, set Visual Studio Code (VS Code) as the default editor, and install the GitHub CLI, all using the command line.
In this example, we’ll use the winget and git commands to install and configure Git on your local PC.
winget install --id Git.Git -e --source winget

Git will now be available from the command line and PowerShell. You will also find the Git GUI and Git Bash applications installed on your PC.
git --version

Now let’s set VS Code as the default code editor for Git. If you don’t already have VS Code on your PC, you can install it using WinGet:
winget install -e --id Microsoft.VisualStudioCode
Now let’s set VS Code as the default code editor for Git:
git config --global core.editor "code --wait"
git config --global -e

This step is optional, but if you want to create and work with repositories hosted on GitHub, it’s also handy to have the GitHub CLI installed on your PC.
winget install --id GitHub.cli
gh --version
Now you need to authenticate to GitHub before you can start working with remote repositories (repo):
gh auth login

Now you can start using the git and gh command line tools to manage remote and local repositories.
Whether you are working alone or with a team, using Git adds version control to your scripting efforts. Git is to code what SharePoint is to document management. Here are some advantages of using Git to manage your PowerShell scripts:
You can use the POSH-GIT PowerShell module to manage Git instead of the git command line. POSH-GIT is installed as part of Git for Windows.
A version of Git is bundled with GitHub Desktop (GitHub for Windows). So, technically you don’t need to install Git for Windows if you are already using GitHub Desktop. But if you want access to Git Bash and the full range of Git commands, you’ll need to install Git for Windows.
If you want to perform any of the following operations, you’ll need to have Git installed locally on your PC:
To install Git on Windows, download the latest installer from the official Git website. Run the installer, follow the setup wizard, and choose your preferred options (such as default editor and PATH settings). Once installed, you can verify by opening Command Prompt or PowerShell and typing git --version.
Yes. Git for Windows is a specific version of Git tailored for the Windows operating system. It includes the Git command-line tools and Git Bash, a terminal emulator that supports Unix-style commands. You can get it from gitforwindows.org.
By default, Git is usually installed in C:\Program Files\Git or C:\Program Files (x86)\Git. You can also check the installation path by typing where git in Command Prompt or PowerShell. This command will display the exact directory where Git is located.
Git cannot be installed using pip because it is not a Python package; it’s a version control system. To install Git, you need to download the installer from the official Git website or use a package manager like Chocolatey (choco install git) or Winget (winget install --id Git.Git -e).