Created
June 3, 2016 18:07
-
-
Save vfalconi/affea55a19c819903dfc82b17e7184bd to your computer and use it in GitHub Desktop.
Powershell script to undo a git-push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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