Created
September 26, 2025 07:06
-
-
Save denisdefreyne/c4ab29a5460c827404d680c1b0bf90d6 to your computer and use it in GitHub Desktop.
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
| function git_sync --description 'Brings all Git branches up to date' | |
| set -l orig_branch (git rev-parse --abbrev-ref HEAD) | |
| set -l repo_path (git rev-parse --show-toplevel) | |
| set -l main_branch_name | |
| if git show-ref --verify --quiet refs/heads/master | |
| set main_branch_name master | |
| else if git show-ref --verify --quiet refs/heads/main | |
| set main_branch_name main | |
| else | |
| echo "unknown main branch name" | |
| exit 1 | |
| end | |
| echo "Using $main_branch_name as the main branch" | |
| echo | |
| git checkout $main_branch_name | |
| git fetch | |
| git pull | |
| echo | |
| for line in (git branch --no-color | egrep -v "^. *($main_branch_name|denis/archive/|archive/|gh-pages)") | |
| set -l branch (echo $line | cut -b 3-) | |
| echo "*** Rebasing $branch..." | |
| git checkout $branch | |
| git rebase $main_branch_name | |
| if test -e $repo_path/.git/rebase-merge -o -e $repo_path/.git/rebase-apply | |
| git rebase --abort | |
| end | |
| echo | |
| end | |
| echo "*** Finishing up..." | |
| git checkout $main_branch_name | |
| git-atpc | |
| git remote prune origin | |
| git checkout $orig_branch | |
| echo | |
| echo "Your active branches:" | |
| git branch --no-color | egrep -v "^. *($main_branch_name|denis/archive/|archive/)" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment