Last active
February 20, 2026 15:33
-
-
Save larouxn/3bc34f8952b5753461a023e89d63e12c to your computer and use it in GitHub Desktop.
🚢 rebasecity branch_name 🚀
This file contains hidden or 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
| # Â Â Â Â Â Â Â Â Â Â _Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _Â _Â Â Â Â Â Â Â Â Â | |
| # Â Â Â Â Â Â Â Â Â |Â |Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (_)Â |Â Â Â Â Â Â Â Â | |
| # Â _Â __Â ___|Â |__Â Â Â __Â _Â ___Â Â ___Â Â ___Â _|Â |_Â _Â Â Â _Â | |
| # |Â '__/Â _Â \Â '_Â \Â /Â _`Â /Â __|/Â _Â \/Â __|Â |Â __|Â |Â |Â | | |
| # |Â |Â |Â Â __/Â |_)Â |Â (_|Â \__Â \Â Â __/Â (__|Â |Â |_|Â |_|Â | | |
| # |_|  \___|_.__/ \__,_|___/\___|\___|_|\__|\__, | | |
| # Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â __/Â | | |
| # Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |___/Â | |
| # | |
| # ascii art thanks tro https://calligraphy.geopjr.dev/ | |
| # | |
| # Rebase whatever branch you like against your latest primary branch. | |
| # Use: rebasecity branch_name | |
| # | |
| # Helper function to dynamically detect the primary branch | |
| _git_default_branch() { | |
| # Check if 'main' exists locally or on the remote | |
| if git rev-parse --verify --quiet refs/heads/main >/dev/null || \ | |
| git rev-parse --verify --quiet refs/remotes/origin/main >/dev/null; then | |
| echo "main" | |
| else | |
| echo "master" | |
| fi | |
| } | |
| # Fetch primary, checkout target, rebase, and force push | |
| rebasecity() { | |
| local primary=$(_git_default_branch) | |
| git fetch origin "$primary" && \ | |
| git checkout "$@" && \ | |
| git rebase "origin/$primary" && \ | |
| git push origin --force-with-lease "$@" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment