Like git pull --rebase? Make it default
As I mentioned in one of the previous protips git pull --rebase is a way to go (for most cases).
But what if you're tired of writing --rebase every single time?
Make it default.
For your repo config just set
git config branch.autosetuprebase always
and every new branch will be set to use rebase when you type git pull.
What about existing branches? Type for each of them
git config branch.YOUR_BRANCH_NAME.rebase true
If you want to use merge instead of rebase for one particular pull you can always type
git pull --no-rebase
Written by Krzysztof Hasiński
Related protips
8 Responses
Git pull is dead. You bring it back to life Dr. Frankenstein ;)
For existing branches:
$ for branch in $(git for-each-ref --format='%(refname)' -- refs/heads/); do git config branch."${branch#refs/heads/}".rebase true; done
possible to get this for every git repo locally ? a kind of global configuration of git ?
This is very dangerous! Your adjusting the default behavior of git pull. If you are on a system that isn't setup correctly, than you will merge instead of rebase.
If you create a short alias for git pull --rebase, or use the full command, you will never get into trouble!
No it isn't. You can set it up per repository, you can have your global settings changes. It's your account. If you switch a lot between different machines it's nice to have your config shared between them anyway.
Alias way is good too, but autorebase is in no way dangerous.
You can always bring back merge by doing git pull --no-rebase
Besides - it's git. If you haven't pushed it to a remote repository you can always fix it ;)
You change default behavior of a command, that is the dangerous part i'm talking about. Perhaps it's personal preference, but I wouldn't do it. Just to prevent screw ups!
If you need to update a repo on a remote server, you first need to check the behavior of git pull otherwise you will need to fix stuff
I agree with you that it's always fixable.
I also change my config for vim, bash and many other things. It's still your account on the remote server. If it isn't you're using verbose, long commands and do not have aliases anyway. And that's when you type git pull --rebase
;)