pierrefevrier
pierrefevrier

Reputation: 1650

Git pull --rebase when push

I'd like to know if it would be possible with git to auto pull --rebase when doing git push ?

I mean if git push is rejected, automatically do a git pull --rebase and then git push again so I don't need to do that manually each time someone push before me.

Thanks for your answers.

Upvotes: 2

Views: 468

Answers (1)

René Link
René Link

Reputation: 51473

You might want to do

git pull --rebase && git push

Maybe you want to create an alias for this

git config --global alias.rbpush '! git pull --rebase && git push'

and then invoke it using:

git rbpush

But keep in mind that the rebase might cause conflits that you have to solve. And while you are solving the conflicts another developer might push in the meanwhile.

[EDIT] Remove "_" in alias's name because git doesn't parse them.

Upvotes: 7

Related Questions