Skip to content

Set-GitHubRepository

SYNOPSIS

Creates or updates a repository.

SYNTAX

Set a repository for the authenticated user (Default)

Set-GitHubRepository -Name <String> [-AddReadme] [-Gitignore <String>] [-License <String>]
 [-Visibility <String>] [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>]
 [-IsTemplate <Boolean>] [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>]
 [-HasIssues <Boolean>] [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>] [-HasProjects <Boolean>]
 [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>] [-AllowRebaseMerging <Boolean>]
 [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>] [-DeleteBranchOnMerge <Boolean>]
 [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>] [-EnableSecretScanning <Boolean>]
 [-EnableSecretScanningPushProtection <Boolean>] [-EnableSecretScanningAIDetection <Boolean>]
 [-EnableSecretScanningNonProviderPatterns <Boolean>] [-Context <Object>] [-ProgressAction <ActionPreference>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Set a repository from a template to an organization

Set-GitHubRepository -Organization <String> -Name <String> -TemplateOwner <String> -TemplateRepository <String>
 [-IncludeAllBranches] [-Visibility <String>] [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>]
 [-IsTemplate <Boolean>] [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>]
 [-HasIssues <Boolean>] [-AllowForking <Boolean>] [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>]
 [-HasProjects <Boolean>] [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>]
 [-AllowRebaseMerging <Boolean>] [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>]
 [-DeleteBranchOnMerge <Boolean>] [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>]
 [-EnableSecretScanning <Boolean>] [-EnableSecretScanningPushProtection <Boolean>]
 [-EnableSecretScanningAIDetection <Boolean>] [-EnableSecretScanningNonProviderPatterns <Boolean>]
 [-Context <Object>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set a forked repository in an organization

Set-GitHubRepository -Organization <String> [-Name <String>] -ForkOwner <String> -ForkRepository <String>
 [-IncludeAllBranches] [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>]
 [-IsTemplate <Boolean>] [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>]
 [-HasIssues <Boolean>] [-AllowForking <Boolean>] [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>]
 [-HasProjects <Boolean>] [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>]
 [-AllowRebaseMerging <Boolean>] [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>]
 [-DeleteBranchOnMerge <Boolean>] [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>]
 [-EnableSecretScanning <Boolean>] [-EnableSecretScanningPushProtection <Boolean>]
 [-EnableSecretScanningAIDetection <Boolean>] [-EnableSecretScanningNonProviderPatterns <Boolean>]
 [-Context <Object>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set a repository in an organization

Set-GitHubRepository -Organization <String> -Name <String> [-AddReadme] [-Gitignore <String>]
 [-License <String>] [-Visibility <String>] [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>]
 [-IsTemplate <Boolean>] [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>]
 [-HasIssues <Boolean>] [-AllowForking <Boolean>] [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>]
 [-HasProjects <Boolean>] [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>]
 [-AllowRebaseMerging <Boolean>] [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>]
 [-DeleteBranchOnMerge <Boolean>] [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>]
 [-EnableSecretScanning <Boolean>] [-EnableSecretScanningPushProtection <Boolean>]
 [-EnableSecretScanningAIDetection <Boolean>] [-EnableSecretScanningNonProviderPatterns <Boolean>]
 [-Context <Object>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set a forked repository for a user

Set-GitHubRepository [-Name <String>] -ForkOwner <String> -ForkRepository <String> [-IncludeAllBranches]
 [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>] [-IsTemplate <Boolean>]
 [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>] [-HasIssues <Boolean>]
 [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>] [-HasProjects <Boolean>]
 [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>] [-AllowRebaseMerging <Boolean>]
 [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>] [-DeleteBranchOnMerge <Boolean>]
 [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>] [-EnableSecretScanning <Boolean>]
 [-EnableSecretScanningPushProtection <Boolean>] [-EnableSecretScanningAIDetection <Boolean>]
 [-EnableSecretScanningNonProviderPatterns <Boolean>] [-Context <Object>] [-ProgressAction <ActionPreference>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Set a repository from a template to a user

Set-GitHubRepository -Name <String> -TemplateOwner <String> -TemplateRepository <String> [-IncludeAllBranches]
 [-Visibility <String>] [-Description <String>] [-Homepage <Uri>] [-IsArchived <Boolean>]
 [-IsTemplate <Boolean>] [-WebCommitSignoffRequired <Boolean>] [-DefaultBranch <String>] [-HasWiki <Boolean>]
 [-HasIssues <Boolean>] [-HasSponsorships <Boolean>] [-HasDiscussions <Boolean>] [-HasProjects <Boolean>]
 [-AllowMergeCommitWith <String>] [-AllowSquashMergingWith <String>] [-AllowRebaseMerging <Boolean>]
 [-SuggestUpdateBranch <Boolean>] [-AllowAutoMerge <Boolean>] [-DeleteBranchOnMerge <Boolean>]
 [-EnableAdvancedSecurity <Boolean>] [-EnableCodeSecurity <Boolean>] [-EnableSecretScanning <Boolean>]
 [-EnableSecretScanningPushProtection <Boolean>] [-EnableSecretScanningAIDetection <Boolean>]
 [-EnableSecretScanningNonProviderPatterns <Boolean>] [-Context <Object>] [-ProgressAction <ActionPreference>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Checks if the specified repository exists. If it does, the repository is updated using the provided parameters. If it does not exist, a new repository is created with the provided parameters. The updated or newly created repository is returned.

EXAMPLES

EXAMPLE 1

Set-GitHubRepository -Name 'Hello-World' -Description 'My repo'

Sets the repository Hello-World for the authenticated user if it does not exist, or updates it if it already exists. The repository uses GitHub's default settings.

EXAMPLE 2

$params = @{
    Owner                  = 'octocat'
    Name                   = 'Hello-World'
    AllowSquashMergingWith = 'Pull request title and description'
    HasIssues              = $true
    SuggestUpdateBranch    = $true
    AllowAutoMerge         = $true
    DeleteBranchOnMerge    = $true
}
Set-GitHubRepository @params

Sets a repository using splatting for the configuration.

PARAMETERS

-Organization

The account owner of the repository. The name is not case sensitive.

Type: String
Parameter Sets: Set a repository from a template to an organization, Set a forked repository in an organization, Set a repository in an organization
Aliases: Owner

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Name

The name of the repository.

Type: String
Parameter Sets: Set a repository for the authenticated user, Set a repository from a template to an organization, Set a repository in an organization, Set a repository from a template to a user
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: Set a forked repository in an organization, Set a forked repository for a user
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-TemplateOwner

The account owner of the template repository. The name is not case sensitive.

Type: String
Parameter Sets: Set a repository from a template to an organization, Set a repository from a template to a user
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-TemplateRepository

The name of the template repository without the .git extension. The name is not case sensitive.

Type: String
Parameter Sets: Set a repository from a template to an organization, Set a repository from a template to a user
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ForkOwner

The account owner of the repository. The name is not case sensitive.

Type: String
Parameter Sets: Set a forked repository in an organization, Set a forked repository for a user
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ForkRepository

The name of the repository without the .git extension. The name is not case sensitive.

Type: String
Parameter Sets: Set a forked repository in an organization, Set a forked repository for a user
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IncludeAllBranches

Include all branches from the source repository.

Type: SwitchParameter
Parameter Sets: Set a repository from a template to an organization, Set a forked repository in an organization, Set a forked repository for a user, Set a repository from a template to a user
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-AddReadme

Pass true to Set an initial commit with empty README.

Type: SwitchParameter
Parameter Sets: Set a repository for the authenticated user, Set a repository in an organization
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Gitignore

The desired language or platform to apply to the .gitignore.

Type: String
Parameter Sets: Set a repository for the authenticated user, Set a repository in an organization
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-License

The license keyword of the open source license for this repository.

Type: String
Parameter Sets: Set a repository for the authenticated user, Set a repository in an organization
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Visibility

The visibility of the repository.

Type: String
Parameter Sets: Set a repository for the authenticated user, Set a repository from a template to an organization, Set a repository in an organization, Set a repository from a template to a user
Aliases:

Required: False
Position: Named
Default value: Public
Accept pipeline input: False
Accept wildcard characters: False

-Description

A short description of the new repository.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Homepage

A URL with more information about the repository.

Type: Uri
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IsArchived

Whether the repository is archived.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IsTemplate

Whether this repository acts as a template that can be used to generate new repositories.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WebCommitSignoffRequired

Whether to require contributors to sign off on web-based commits.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DefaultBranch

Updates the default branch for this repository.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasWiki

Whether the wiki is enabled.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasIssues

Whether issues are enabled.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AllowForking

Either true to allow private forks, or false to prevent private forks.

Type: Boolean
Parameter Sets: Set a repository from a template to an organization, Set a forked repository in an organization, Set a repository in an organization
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasSponsorships

Whether sponsorships are enabled.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasDiscussions

Whether discussions are enabled.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-HasProjects

Whether projects are enabled.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AllowMergeCommitWith

Allow merge commits for pull requests with the specified setting.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Default message
Accept pipeline input: False
Accept wildcard characters: False

-AllowSquashMergingWith

Allow squash merges for pull requests with the specified setting.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Default message
Accept pipeline input: False
Accept wildcard characters: False

-AllowRebaseMerging

Whether to allow rebase merges for pull requests.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SuggestUpdateBranch

Whether to always suggest to update a head branch that is behind its base branch during a pull request.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AllowAutoMerge

Whether to allow Auto-merge to be used on pull requests.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DeleteBranchOnMerge

Whether to delete head branches when pull requests are merged

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableAdvancedSecurity

Whether to enable GitHub Advanced Security for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableCodeSecurity

Whether to enable code security for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableSecretScanning

Whether to enable secret scanning for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableSecretScanningPushProtection

Whether to enable secret scanning push protection for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableSecretScanningAIDetection

Whether to enable secret scanning AI detection for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableSecretScanningNonProviderPatterns

Whether to enable secret scanning non-provider patterns for this repository.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Context

The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

GitHubRepository

NOTES

https://psmodule.io/GitHub/Functions/Repositories/Set-GitHubRepository/