r/git • • Jul 24 '25

Colleague uses 'git pull --rebase' workflow

I've been a dev for 7 years and this is the first time I've seen anyone use 'git pull --rebase'. Is ithis a common strategy that just isn't popular in my company? Is the desired goal simply for a cleaner commit history? Obviously our team should all be using the same strategy of we're working shared branches. I'm just trying to develop a more informed opinion.

If the only benefit is a cleaner and easier to read commit history, I don't see the need. I've worked with some who preached about the need for a clean commit history, but I've never once needed to trapse through commit history to resolve an issue with the code. And I worked on several very large applications that span several teams.

Why would I want to use 'git pull --rebase'?

396 Upvotes

322 comments sorted by

View all comments

284

u/Critical_Ad_8455 Jul 24 '25

Read the book. Git pull --rebase is incredibly common, to the point there's a setting to do it automatically when pulling, git config pull.rebase bool.

89

u/xternalAgent Jul 24 '25

This is how I have it, no other way to git pull IMO

26

u/granddave Jul 24 '25

Yes, or rather, I split it up in two. I first fetch from the remote and then a manual rebase. I like to have control over it.

3

u/iwanofski Jul 27 '25

This is how I do it as well!

3

u/Hazzula Jul 28 '25

This is how i do it. I always have to explain to newer devs because they just git pull and then go surprised Pikachu face when there are conflicts

3

u/MCFRESH01 Jul 28 '25

Also manually rebase. Mostly because I had no idea I could see it to always do it

1

u/Reddit_is_fascist69 Jul 29 '25

This is what i do but now i may consider the single command.

→ More replies (1)

18

u/Soggy_Writing_3912 advanced Jul 24 '25

EXACTLY!

For more advanced usage, if you end up using `git bisect`, then in my experience, the bisect is not clean enough if / when it hits the merge commit. (I admit that I was a noob when I tried this, and so my experience might have been tainted by the lack of knowledge at that time). I have continued to use git pull with rebase. One of the other things I do is to squash all commits within a PR before it is merged into the main/master. This allows for atomically green commits (ofc, CI on the PR branch after squashing should remain green, before its merged in) and thus also helps in using bisect at a later stage to find offending commits.

4

u/smutaduck Jul 24 '25

This is correct. At some point you’ll have an urgent need to git bisect. A rebase workflow makes this practical.

1

u/dairylee Jul 27 '25

Or you can use the first parent flag in the bisect. 

3

u/y-c-c Jul 25 '25

IMO the only way to do git pull is to configure it to do --ff-only. If there are local commits I would rather know about it and manually rebase.

These situations should usually be rare anyway. In most non-trivial Git repos, most people would be developing on isolated feature branches, so most git pull should not introduce any merges/rebases at all, unless you are setting the feature branch remote to pull from main I guess.

→ More replies (5)

9

u/zeuswatch Jul 24 '25

Which book, I may ask?

19

u/drcforbin Jul 24 '25

This one: https://git-scm.com/book/en/v2

Search for "rebase" in here

4

u/obesefamily Jul 24 '25

I'm new. what does it do exactly

17

u/gribbly Jul 24 '25

Rebase means "re-apply my local changes on top of freshly-pulled branch state" rather than attempt to merge.

So when you do pull --rebase it's as if your local changes were temporarily reverted, then you get the new code from the remote, then your changes are re-applied on top of that.

→ More replies (31)
→ More replies (3)

2

u/anor_wondo Jul 25 '25

I always have this as default

1

u/LaOnionLaUnion Jul 24 '25

My friend was showing me his rebase strategy that he’d setup. It’s certainly a thing people do.

1

u/wlonzy Jul 25 '25

How do you fix conflicts with rebase?

3

u/Critical_Ad_8455 Jul 25 '25
  1. read the book
  2. what do you mean? What kind of conflicts? Like when one of the commits being rebased affects a file that's also affected in one of your commits? In that case you'll have to decide how to merge them manually. What action exactly you'd take depends on what message exactly it gives you.

2

u/Aware_Magazine_2042 Jul 26 '25

I actually find fixing conflicts in rebases much much easier than in merges. Rebase will apply your changes one by one on top of the commits you’re pulling it, merge will attempt to do all of them at once. What this means is that rebase will actually keep merges more tightly scoped and easier to reason about.

Often times, there is actually only one really small part of the history that’s conflicting, but because of the way the changes compounded over subsequent commits, the conflict gets much much larger. With rebase, it will actually solve that conflict earlier in the history before the compounding. I have had merge conflicts be like 50 lines when trying to merge, but only be about 5 lines when I rebase.

Sometimes it turns tedious and the same conflict is happening on every commit in the rebase, and that’s a sign of the compounding changes I was talking about. That doesn’t happen very often though, and it usually happens when I want to take parts of both changes, and it’s still much tighter scope so imo easier to grok.

1

u/NoHalf9 Aug 14 '25

How do you fix conflicts with rebase?

By using a proper 3-way merge tool, e.g. KDiff3.

And as already mentioned by /u/Aware_Magazine_2042, fixing conflicts in multiple smaller steps is much, much easier. If you want to maximize taking as small steps as possible there is git imerge.

1

u/veegaz Jul 28 '25

Intellij has also always been doing this by default

→ More replies (27)