diff options
| author | Raul Benencia <raul@thousandeyes.com> | 2026-07-08 10:55:40 -0700 |
|---|---|---|
| committer | Raul Benencia <raul@thousandeyes.com> | 2026-07-08 10:55:40 -0700 |
| commit | 8e5a3f9b411f19d287acd1f2ec3fa7fb14ea0247 (patch) | |
| tree | 8f72cdecc106110bf66e36bd465829ce2535efcb | |
| parent | ede8b2ba7acb5d70fb46bd57b45ec4aedce73855 (diff) | |
alias: generalize gcm
| -rw-r--r-- | .alias.d/10-git | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/.alias.d/10-git b/.alias.d/10-git index ac82cda..48246c1 100644 --- a/.alias.d/10-git +++ b/.alias.d/10-git @@ -139,10 +139,19 @@ main_branch() { } gcm() { - branch=$(main_branch) - git checkout "$branch" - git fetch upstream - git reset --hard "upstream/${branch}" + local branch + + branch=$(main_branch) || return + + if ! git diff --quiet || ! git diff --cached --quiet; then + echo "Aborting: you have uncommitted changes." + git status --short + return 1 + fi + + git checkout "$branch" || return + git fetch origin || return + git reset --hard "origin/${branch}" } gfr() { |
