Last active
August 18, 2021 17:20
-
-
Save GMNGeoffrey/a1a2cc1baf811ce4ebcdeab6c24e8a2d to your computer and use it in GitHub Desktop.
git-sudo
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
#!/bin/bash | |
# Copyright 2021 Google LLC. | |
# SPDX-License-Identifier: Apache-2.0 | |
# Protect yourself from accidentally pushing upstream. Leave the | |
# upstream push URL as a fake DISABLE. Then temporarily enable pushes | |
# when you do need them with this custom git subcommand. Run: | |
# `git sudo [command]` to run the `command` but with pushing to | |
# upstream enabled, e.g. `git sudo push upstream main` | |
git remote set-url --delete --push upstream DISABLE | |
git "$@" | |
git remote set-url upstream --push DISABLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment