Russell Smith, the Editorial Director at Petri IT Knowledgebase, has over two decades of hands-on experience in IT, in both small business settings and government IT infrastructure projects. Russell started writing for Windows IT Pro Magazine in t...
Apart from the amusing name, POSH-GIT is a PowerShell module for GitHub supplied as part of Git for Windows. In this Ask the Admin, I’ll show you how to use Git source control via this PowerShell module.
If you’ve been following my series on GitHub, you’ll understand the basics of Git, GitHub and how to work with GitHub for Windows, the free GUI tool. Git is an open-source versioning system for code, which when used with a hub – think GitHub – allows developers to collaborate on projects in the cloud. When GitHub for Windows is installed, the PowerShell module for GitHub, Git Shell, is also installed, allowing you to clone repositories, send pull requests, among other things, all from the command line.
For more information on Git and GitHub, see What is GitHub?, Create a GitHub Repository, and GitHub for Windows – Installation, Adding Accounts, Committing Changes, and Syncing Repos on the Petri IT Knowledgebase.
Make sure that GitHub for Windows is installed, and open the Git Shell by double clicking the Git Shell icon on your desktop. You can alternatively use Import-Module Posh-Git to import the module, but you’ll need to change the working directory, or specify the full path to the posh-git.psm1 PowerShell module file, to the GitHub for Windows LocalAppData directory.
To clone a repo from GitHub, you first need the download URI.
git clone git://github.com/dahlbyk/posh-git.git
Some repos can only be cloned using a secure connection. To add that ability to Git Shell, you’ll need to generate an SSH key as follows:
Let’s create a new repo on the local PC with no connection to GitHub.
Let’s commit changes we’ve made to a repo.
Once the files have been committed, we can push the repo to GitHub.
git request-pull v1.0 https://github.com/user/petri_testing.git
Related Article: