I would argue that it's not a good idea to do this for all branches by default. For example, we do the opposite for 'master', we force merge commits (--no-ff) on master/integration branches but use pull --rebase on feature branches that we share.
autosetuprebase is annoying because it doesn't apply to any already existing branches, and because it's configuring a per-branch setting going forward, if you ever want to change the setting later after you have a lot of branches, you're going to be making a lot of config changes in a lot of places. Instead you can just do:
git config --global pull.rebase true
I would recommend that you do not do this. I rebase probably 80% of my pull requests, but sometimes you do want a merge commit. Instead, I setup an alias for git pull --rebase
This also helps when pairing with someone else. The process of handling a rebase conflict vs pull/merge (regular pull) is quite different.
if you want to do a merge commit sometimes, but pull --rebase most of the time, why not make pull --rebase the default, and do a fetch && merge when that's what you want?
Example: I am working on a local branch feature/xyz. I decide I am done my work and merge feature/xyz -> master. I get ready to push and realize I am 5 commits behind origin/master. How do I fetch them now?
If you use git --rebase it will clobber your feature branch merge commit. On the other hand if you do a fetch & merge this also probably is not what you want (you will have a merge-commit on top of your merge commit, dawg). git rebase -p is probably the best option in this scenario.
Once you find out your master (B) is behind, because say there's G-H-I on origin, you'd want to rebase onto that. So you use the 3-argument form of git rebase --onto:
git rebase --onto origin/master C~1 E
Which would take C's old base, C~1 (B), and replace it with origin/master, but only up to E.
Or, if you still had the branch around that you merged into master (which you do, in many forms, including the reflog, even after you delete the branch).
Ah awesome, I love there are so many things to learn about git.
I knew about git rebase -p and its nuances, but haven't known about the --onto until now. The 3-argument form of git rebase --onto in your blog post was great, thanks!
For me, my alias 'git pr' is shorter than 'git pull'. For the person working with me, not being in a rebase when they didn't expect to be is also a boon.