Skip to content

Rename‑GitRemote

viscalyxbot edited this page Sep 30, 2025 · 1 revision

SYNOPSIS

Renames a Git remote to a new name.

SYNTAX

Rename-GitRemote [-Name] <String> [-NewName] <String> [-Force] [-WhatIf]
 [-Confirm] [<CommonParameters>]

DESCRIPTION

This function renames a Git remote in the current repository. It wraps the 'git remote rename' command and provides proper error handling and validation.

EXAMPLES

EXAMPLE 1

Rename-GitRemote -Name "my" -NewName "origin"

This example renames the Git remote from "my" to "origin".

EXAMPLE 2

Rename-GitRemote -Name "upstream" -NewName "fork"

This example renames the Git remote from "upstream" to "fork".

EXAMPLE 3

Rename-GitRemote -Name "my" -NewName "origin" -Force

This example renames the Git remote from "my" to "origin" without prompting for confirmation.

PARAMETERS

-Force

Forces the rename operation to proceed without confirmation prompts.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Name

The current name of the remote to be renamed.

Type: String
Parameter Sets: (All)
Aliases:

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

-NewName

The new name for the remote.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
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

-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

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

None

This function does not accept pipeline input.

OUTPUTS

None

This function does not return any output.

NOTES

This function requires Git to be installed and accessible in the system PATH. The remote being renamed must exist in the current Git repository.

RELATED LINKS

Clone this wiki locally