{"id":13529266,"url":"https://github.com/Iristyle/Posh-GitHub","last_synced_at":"2025-04-01T15:30:43.572Z","repository":{"id":4803299,"uuid":"5956549","full_name":"Iristyle/Posh-GitHub","owner":"Iristyle","description":"Powershell cmdlets that expose the GitHub API","archived":false,"fork":false,"pushed_at":"2016-08-10T13:42:41.000Z","size":314,"stargazers_count":75,"open_issues_count":32,"forks_count":28,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-02T15:36:33.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Iristyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-25T20:57:27.000Z","updated_at":"2024-09-13T09:47:19.000Z","dependencies_parsed_at":"2022-08-18T22:01:18.667Z","dependency_job_id":null,"html_url":"https://github.com/Iristyle/Posh-GitHub","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iristyle%2FPosh-GitHub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iristyle%2FPosh-GitHub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iristyle%2FPosh-GitHub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iristyle%2FPosh-GitHub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Iristyle","download_url":"https://codeload.github.com/Iristyle/Posh-GitHub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246662245,"owners_count":20813716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:00:34.895Z","updated_at":"2025-04-01T15:30:43.216Z","avatar_url":"https://github.com/Iristyle.png","language":"PowerShell","funding_links":[],"categories":["API Wrapper","PowerShell"],"sub_categories":[],"readme":"![PowerShell Logo](powershell_logo.png) ![GitHub Mark](GitHub-Mark.png)\r\n\r\n# Posh-GitHub\r\n\r\nUnofficial Powershell cmdlets that expose the GitHub API\r\n\r\n## Early Code\r\n\r\nThis is a super super early take on some rudimentary GitHub functionality.\r\nI will continue to improve this over time as need grows / time allows.  There\r\nmay be bugs or things I haven't thought of -- please report if that's the case!\r\n\r\n## Compatibility\r\n\r\n* This is written for Powershell v3 and makes use of the simplified\r\n[Invoke-RestMethod][invoke-rest] instead of the `WebClient` class.\r\n  * Powershell v3 can be installed with [Chocolatey][Choc] via `cinst powershell`\r\n\r\n* This is written against GitHub API v3\r\n\r\n[invoke-rest]: http://technet.microsoft.com/en-us/library/hh849971.aspx\r\n[Choc]: http://www.chocolatey.org\r\n\r\n## Installation\r\n\r\n### Chocolatey\r\n\r\nOnce Chocolatey has been installed, simply use the `cinst` command.\r\n\r\n```powershell\r\ncinst posh-github\r\n```\r\n\r\nChocolatey installation will import the module into your PowerShell profile.\r\n\r\n## Updating\r\n\r\n### Chocolatey\r\n\r\nAfter installing with Chocolatey, simply use the `cup` command.\r\n\r\n```powershell\r\ncup posh-github\r\n```\r\n\r\n## Supported Commands\r\n\r\n### Environment Variables\r\n\r\nCmdlets are set to use the following environment variables as defaults\r\n\r\n* `GITHUB_OAUTH_TOKEN` - Required for all cmdlets - use `New-GitHubOAuthToken`\r\n  to establish a token and automatically set this variable for the current user\r\n* `GITHUB_USERNAME` - Can be optionally set to specify a global default user -\r\nuse the `Set-GitHubUserName` helper\r\n* `GITHUB_ORGANIZATION` - Can be optionally set to specify a global default\r\norganization - use the `Set-GitHubOrganization` helper\r\n\r\n### Last Command Output\r\n\r\nA Powershell object created from the incoming JSON is always stored\r\nin the variable `$GITHUB_API_OUTPUT` after each call to the GitHub API\r\n\r\n### New-GitHubOAuthToken\r\n\r\nUsed to create a new OAuth token for use with the GitHub using your\r\nusername/password in basic auth over HTTPS.  The result is stashed in the\r\n`GITHUB_OAUTH_TOKEN` environment variable.\r\n\r\n```powershell\r\nNew-GitHubOAuthToken -UserName Bob -Password bobpassword\r\n```\r\n\r\n```powershell\r\nNew-GitHubOAuthToken -UserName Bob -Password bobpassword -NoEnvironmentVariable\r\n```\r\n\r\n### Get-GitHubOAuthTokens\r\n\r\nUsed to list all the authorizations you have provided to applications / tooling\r\n\r\n```powershell\r\nGet-GitHubOAuthTokens Bob bobspass\r\n```\r\n\r\n### Set-GitHubUserName\r\n\r\nAdds the username to the current Powershell session and sets a global User\r\nenvironment variable\r\n\r\n```powershell\r\nSet-GitHubUserName Iristyle\r\n```\r\n\r\n### Set-GitHubOrganization\r\n\r\nAdds the organization to the current Powershell session and sets a global User\r\nenvironment variable\r\n\r\n```powershell\r\nSet-GitHubOrganization EastPoint\r\n```\r\n\r\n### Get-GitHubRepositories\r\n\r\nList all your repositories - gives a fork indicator, a date for when the last\r\nupdate (push) occurred, how many open issues and size\r\n\r\n```powershell\r\nGet-GitHubRepositories\r\n```\r\n\r\n```powershell\r\nGet-GitHubRepositories -Type owner -Sort pushed\r\n```\r\n\r\n### New-GitHubRepository\r\n\r\nCreates a new GitHub repository and clones it locally by default.\r\n\r\nBy default creates a public repository for the user configured by\r\n`GITHUB_USERNAME`, and clones it afterwards.\r\n\r\n```powershell\r\nNew-GitHubRepository MyNewRepository\r\n```\r\n\r\nIf you are a member of an organization and have set a `GITHUB_ORG` environment\r\nvariable, this will create the repository under that organization.  Note that\r\norganization repositories require a TeamId\r\n\r\n```powershell\r\nNew-GitHubRepository MyNewOrgRepo -ForOrganization -TeamId 1234\r\n```\r\n\r\nIf you are a member of multiple organizations you may override the default\r\nconfigured organization\r\n\r\n```powershell\r\nNew-GitHubRepository MyNewOrgRepo -Organization DifferentOrg -TeamId 1234\r\n```\r\n\r\nA fancier set of switches -- pretty self-explanatory.\r\nThe complete [Gitignore list][gitignore] here is at your disposal.\r\n\r\n```powershell\r\nNew-GitHubRepository RepoName -Description 'A New Repo' `\r\n  -Homepage 'https://www.foo.com' -Private -NoIssues -NoWiki -NoDownloads `\r\n  -AutoInit -GitIgnoreTemplate 'CSharp' -NoClone\r\n```\r\n\r\n[gitignore]: https://github.com/github/gitignore\r\n\r\n### New-GitHubFork\r\n\r\nForks a repository, clones it locally, then properly adds a remote named\r\n`upstream` to point back to the parent repository.  Aborts if there is a\r\ndirectory in the current working directory that shares the name of the\r\nrepository.\r\n\r\nUses the environment variable `GITHUB_OAUTH_TOKEN` to properly fork to your\r\naccount.  After forking, clones the original source, resets origin to the new\r\nurl for your account `https://github.com/YOURUSERNAME/Posh-GitHub.git`,\r\nand sets the upstream remote to `https://github.com/Iristyle/Posh-GitHub.git`\r\n\r\n```powershell\r\nNew-GitHubFork Iristyle 'Posh-GitHub'\r\n```\r\n\r\nPerforms the same operation as above, instead forking to the default\r\norganization specified by the `GITHUB_ORG` environment variable.\r\n\r\n```powershell\r\nNew-GitHubFork Iristyle 'Posh-GitHub' -ForOrganization\r\n```\r\n\r\nPerforms the same operation as above, instead forking to a user specified\r\norganization specified by the `-Organization` switch.\r\n\r\n```powershell\r\nNew-GitHubFork Iristyle 'Posh-GitHub' -Organization MySecondOrganization\r\n```\r\n\r\nForks the repository, without calling `git clone` after the fork.\r\n\r\n```powershell\r\nNew-GitHubFork -Owner Iristyle -Repository 'Posh-GitHub' -NoClone\r\n```\r\n\r\n### Get-GitHubIssues\r\n\r\nList issues against the repository for the current working directory,\r\nor can list issues against a specific repo and owner.\r\n\r\nSimply list issues for the current working directory repository.  Checks first\r\nfor an `upstream` remote and falls back to `origin`\r\n\r\nIf the current directory is not a repository, then lists all the issues assigned\r\nto you, assuming the `GITHUB_OAUTH_TOKEN` has been set properly.\r\n\r\n```powershell\r\nGet-GitHubIssues\r\n```\r\n\r\nTo get your issues regardless of whether or not the current directory is a Git\r\nrepository.\r\n\r\n```powershell\r\nGet-GitHubIssues -ForUser\r\n```\r\n\r\nSame as above, but finds up to the last 30 closed issues.\r\n\r\n```powershell\r\nGet-GitHubIssues -State closed\r\n```\r\n\r\nAll parameters possible when searching for user issues\r\n\r\n```powershell\r\nGet-GitHubIssues -ForUser -State open -Filter created -Sort comments `\r\n  -Direction asc -Labels 'ui','sql' -Since 8/31/2012\r\n```\r\n\r\nMust be ordered by Owner, Repo if not using switches on params\r\n\r\n```powershell\r\nGet-GitHubIssues EastPoint Burden\r\n```\r\n\r\nSwitch on params form\r\n\r\n```powershell\r\nGet-GitHubIssues -Owner EastPoint -Repository Burden\r\n```\r\n\r\nClosed issues\r\n\r\n```powershell\r\nGet-GitHubIssues -Owner EastPoint -Repository Burden -State closed\r\n```\r\n\r\nSupplying all parameters for a repository based issue search\r\n\r\n```powershell\r\nGet-GitHubIssues -Owner EastPoint -Repository Burden -State closed `\r\n  -Milestone '*' -Assignee 'none' -Creator 'Iristyle' -Mentioned 'Iristyle'\r\n  -Labels 'ui','sql' -Sort updated -Direction desc -Since 8/31/2012\r\n```\r\n\r\n### New-GitHubPullRequest\r\n\r\nInitiates a new pull request to the `upstream` repo.\r\n\r\nIf you follow the convention of setting a remote named upstream, and you create\r\nnew branches for new work, then this cmdlet should work mostly automatically\r\nto find the appropriate owner and repo to send the pull request to, and it will\r\nbase it on the origin username and current branch name.\r\n\r\nSupports a title and body.\r\n\r\n```powershell\r\nNew-GitHubPullRequest -Title 'Fixed some stuff' -Body 'More detail'\r\n```\r\n\r\nSupport an issue id.\r\n\r\n```powershell\r\nNew-GitHubPullRequest -Issue 5\r\n```\r\n\r\nSupports a branch other than master to send the pull to.\r\n\r\n```powershell\r\nNew-GitHubPullRequest -Issue 10 -Base 'devel'\r\n```\r\n\r\nIf you don't have a remote set, then override the default sniffing behavior.\r\n\r\n```powershell\r\nNew-GitHubPullRequest -Issue 10 -Owner EastPoint -Repository Burden\r\n```\r\n\r\nIf you're not on the current branch you want to send the pull for, override it.\r\n\r\n```powershell\r\nNew-GitHubPullRequest -Title 'fixes' -Head 'myusername:somebranch'\r\n```\r\n\r\nNote that GitHub generally requires that head be prefixed with `username:`\r\n\r\n### Get-GitHubPullRequests\r\n\r\nList pull requests against the repository for the current working directory,\r\nor can list pull requests against all forks from a user.\r\n\r\nInside of a Git repository, this will look first for a remote named `upstream`\r\nbefore falling back to `origin`.\r\n\r\nInside of a non-Git directory, this will list pulls for all of your forks,\r\nassuming you have set the `GITHUB_USERNAME` environment variable\r\n\r\n```powershell\r\nGet-GitHubPullRequests\r\n```\r\n\r\nWhen inside of a Git directory, the repo lookup behavior may be overridden\r\nwith the `-ForUser` switch, assuming `GITHUB_USERNAME` has been set\r\n\r\n```powershell\r\nGet-GitHubPullRequests -ForUser\r\n```\r\n\r\nWill list all open pull requests the 'Posh-GitHub' repository\r\n\r\n```powershell\r\nGet-GitHubPullRequests -Owner EastPoint -Repository 'Posh-GitHub'\r\n```\r\n\r\nLists all open __public__ pull requests against the given users forks, overriding\r\nthe `GITHUB_USERNAME` default user.\r\n\r\n```powershell\r\nGet-GitHubPullRequests -User Iristyle\r\n```\r\n\r\nWill list all closed pull requests against the 'Posh-GitHub' repository\r\n\r\n```powershell\r\nGet-GitHubPullRequests -Owner EastPoint -Repository 'Posh-Github' -State closed\r\n```\r\n\r\n### Get-GitHubTeams\r\n\r\nThe default parameterless version will use the `GITHUB_ORG` environment variable\r\nto get the list of teams, their ids and members.\r\n\r\n```powershell\r\nGet-GitHubTeams\r\n```\r\n\r\nThis will find all the teams for the EastPoint organization.  You must have\r\naccess to the given organization to list its teams.\r\n\r\n```powershell\r\nGet-GitHubTeams EastPoint\r\n```\r\n\r\n### Get-GitHubEvents\r\n\r\nWill list, in chronological order, the last 30 events that you have generated\r\n\r\n```powershell\r\nGet-GitHubEvents\r\n```\r\n\r\nWill list the public events for another user\r\n\r\n```powershell\r\nGet-GitHubEvents -User Iristyle\r\n```\r\n\r\n### Backup-GitHubRepositories\r\n\r\nThis will clone every repository for the specified user or organization, and will\r\nadditionally clone each fork, as determined by open pull requests.  Does not backup\r\nissues or wiki (yet).\r\n\r\nThe default parameterless version will use the `GITHUB_USERNAME` environment variable\r\nto get the list of repos where the user is an owner or a member, and will backup each\r\none locally to disk\r\n\r\n```powershell\r\nBackup-GitHubRepositories\r\n```\r\n\r\nThis will find all the public repos for the github organization, and will clone each one\r\nlocally\r\n\r\n```powershell\r\nBackup-GitHubRepositories -Organization github\r\n```\r\n\r\n\r\n## Additional Git helper commands\r\n\r\nThese commands do not use GitHub service, but are common enough for inclusion.\r\n\r\n### Clear-GitMergedBranches\r\n\r\nWill remove any local branch cruft from branches that have been merged into\r\nthe master branch.\r\n\r\n```powershell\r\nClear-GitMergedBranches\r\n```\r\n\r\nWhen pull requests have been merged, it's typical to delete the branch after\r\naccepting.  Remotes may no longer have branch names for things that have been\r\nmerged.  This command removes remote branch names that no longer exist.\r\n\r\n```powershell\r\nClear-GitMergedBranches -Remote\r\n```\r\n\r\n## Roadmap\r\n\r\nNone really.. just waiting to see what I might need.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIristyle%2FPosh-GitHub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIristyle%2FPosh-GitHub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIristyle%2FPosh-GitHub/lists"}