Skip to content

Instantly share code, notes, and snippets.

@piraces
Created June 18, 2019 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piraces/e4af2ad13897e4dad3b616c8180afd26 to your computer and use it in GitHub Desktop.
Save piraces/e4af2ad13897e4dad3b616c8180afd26 to your computer and use it in GitHub Desktop.
Powershell script to rename a branch in Git
$oldName = "feature/fix"
$newName = "feature/fixes"
$directory = "C:\Projects\Folder"
Set-Location -Path $directory
git fetch
git checkout $oldName
git pull
git branch -m $newName
git branch -m $oldName $newName
git push origin :$oldName $newName
git push origin -u $newName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment