my git workflow uses rebase a lot. I always fetch upstream changes (the main repo i forked from) and then merge to my branches, and then rebase to remove useless (to me :D) merg
You may use an external tools called git-up, which does exactly what you say for all branches. This will also help you keeping a clean history graph.
I've used for some years and it works pretty well, especially if you are not a git expert. If you add auto-rebasing feature you should know how to properly recover from failing rebase (continue, abort, ...)
Open a shell and run:
sudo gem install git-up
Open your global config file (~/.gitconfig
), and add the following:
[git-up "fetch"]
all = true # up all branches at once, default false
prune = true # prune deleted remote branches, default false
[git-up "rebase"]
# recreate merges while rebasing, default: unset
arguments = --preserve-merges
# uncomment the following to show changed commit on rebase
# log-hook = "git --no-pager log --oneline --color --decorate $1..$2"
See the official documentation for more options.
If everything is configured well, just run:
git up
This is (roughly) equivalent of executing the following:
git stash
git fetch --all
[foreach branch]
git rebase --preserve-merges /
git merge --ff-only
[end foreach]
git checkout
git stash pop