Git fetch-rebase

From razwiki
Revision as of 01:12, 24 March 2022 by Razzi (talk | contribs) (Created page with "I realized I'd been doing a set of manual commands when a coworker called it out. From a feature branch, I'd switch back to the main branch, pull, then switch back to the fea...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I realized I'd been doing a set of manual commands when a coworker called it out.

From a feature branch, I'd switch back to the main branch, pull, then switch back to the feature branch and rebase the main branch.

git switch main
git pull
git switch -
git rebase main

However this can be done without switching branches:

git fetch origin
git rebase origin/main

and I put it in my gitconfig as a single command:

[alias]
 	fetch-rebase = "!git fetch origin && git rebase origin/$(git base)"

and gave it a fish abbr:

abbr -a fr git fetch-rebase

Now I can run

puppet $ git fetch-rebase
Successfully rebased and updated refs/heads/T301565-karapace.