Skip to content

Instantly share code, notes, and snippets.

@vfalconi
Created June 3, 2016 18:07
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 vfalconi/affea55a19c819903dfc82b17e7184bd to your computer and use it in GitHub Desktop.
Save vfalconi/affea55a19c819903dfc82b17e7184bd to your computer and use it in GitHub Desktop.
Powershell script to undo a git-push
function unpush($branch)
{
#
# ever accidentally push a branch to an origin?
# this will undo that. it deletes the remote branch
# and unsets the git-config settings that point
# to the remote branch
#
# if you don't specify a branch, it unpushes the
# current branch
#
if ($branch -eq $null)
{
$branch = GetBranchName
}
git branch -d -r origin/$branch
git config --unset branch.$branch.remote
git config --unset branch.$branch.merge
return "$branch unpushed"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment