Skip to content

New-GitHubRepository

SYNOPSIS

Create a repository for a user or an organization.

SYNTAX

Create a repository for the authenticated user (Default)

New-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>]

Create a repository from a template to an organization

New-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>]

Fork a repository to an organization

New-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>]

Create a repository in an organization

New-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>]

Fork a repository to a user

New-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>]

Create a repository from a template to a user

New-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

Creates a new repository for a user or in a specified organization.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository. Note: For GitHub AE, use repo scope to create an internal repository.
  • repo scope to create a private repository

EXAMPLES

EXAMPLE 1

$params = @{
    Name                     = 'Hello-World'
    Description              = 'This is your first repository'
    Homepage                 = 'https://github.com'
    HasIssues                = $true
    HasProjects              = $true
    HasWiki                  = $true
    HasDiscussions           = $true
    IsTemplate               = $true
    AddReadme                = $true
    AllowSquashMerge         = $true
    AllowAutoMerge           = $true
    DeleteBranchOnMerge      = $true
    SquashMergeCommitTitle   = 'PR_TITLE'
    SquashMergeCommitMessage = 'PR_BODY'
}
New-GitHubRepository @params

Creates a new public repository named "Hello-World" owned by the authenticated user.

EXAMPLE 2

$params = @{
    Organization             = 'PSModule'
    Name                     = 'Hello-World'
    Description              = 'This is your first repository'
    Homepage                 = 'https://github.com'
    HasIssues                = $true
    HasProjects              = $true
    HasWiki                  = $true
    IsTemplate               = $true
    AddReadme                = $true
    AllowSquashMerge         = $true
    AllowAutoMerge           = $true
    DeleteBranchOnMerge      = $true
    SquashMergeCommitTitle   = 'PR_TITLE'
    SquashMergeCommitMessage = 'PR_BODY'
}
New-GitHubRepository @params

Creates a new public repository named "Hello-World" owned by the organization "PSModule".

EXAMPLE 3

$params = @{
    TemplateOwner      = 'GitHub'
    TemplateRepository = 'octocat'
    Organization       = 'PSModule'
    Name               = 'MyNewRepo'
    IncludeAllBranches = $true
    Description        = 'My new repo'
    Visibility         = 'Private'
}
New-GitHubRepository @params

Creates a new private repository named MyNewRepo from the octocat template repository owned by GitHub.

EXAMPLE 4

$params = @{
    ForkOwner         = 'octocat'
    ForkRepo          = 'Hello-World'
    Organization      = 'PSModule'
    Name              = 'MyNewRepo'
    DefaultBranchOnly = $true
}
New-GitHubRepository @params

Creates a new repository named MyNewRepo as a fork of Hello-World owned by octocat. Only the default branch will be forked.

PARAMETERS

-Organization

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

Type: String
Parameter Sets: Create a repository from a template to an organization, Fork a repository to an organization, Create 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: Create a repository for the authenticated user, Create a repository from a template to an organization, Create a repository in an organization, Create 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: Fork a repository to an organization, Fork a repository to 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: Create a repository from a template to an organization, Create 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: Create a repository from a template to an organization, Create 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: Fork a repository to an organization, Fork a repository to 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: Fork a repository to an organization, Fork a repository to 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: Create a repository from a template to an organization, Fork a repository to an organization, Fork a repository to a user, Create 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 create an initial commit with empty README.

Type: SwitchParameter
Parameter Sets: Create a repository for the authenticated user, Create 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: Create a repository for the authenticated user, Create 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: Create a repository for the authenticated user, Create 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: Create a repository for the authenticated user, Create a repository from a template to an organization, Create a repository in an organization, Create 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: Create a repository from a template to an organization, Fork a repository to an organization, Create 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: None
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

Create a repository for the authenticated user Create an organization repository

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