Skip to content

Switch‑GitLocalBranch

viscalyxbot edited this page Sep 30, 2025 · 1 revision

SYNOPSIS

Switches to the specified local Git branch.

SYNTAX

Switch-GitLocalBranch [-Name] <String> [-Force] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

The Switch-GitLocalBranch command is used to switch to the specified local Git branch. It checks if the branch exists and performs the checkout operation. If the checkout fails, it throws an error.

EXAMPLES

EXAMPLE 1

Switch-GitLocalBranch -Name "feature/branch"

This example switches to the "feature/branch" local Git branch.

PARAMETERS

-Force

Forces the operation to proceed without confirmation prompts when similar to -Confirm:$false.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Name

The name of the branch to switch to.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
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 from the command line. The function will check for unstaged or staged changes before switching branches.

RELATED LINKS

Clone this wiki locally