cheatsheet / current
Ways To Push and Sync
This means: **when a pull needs reconciliation, use merge, not rebase**. That does **not** mean “always create a merge commit.” If a fast-forward is possibl
1) git config pull.rebase false
This means: when a pull needs reconciliation, use merge, not rebase. That does not mean “always create a merge commit.” If a fast-forward is possible, Git can still just move the branch pointer forward; otherwise it creates a merge commit. Git’s docs describe pull.rebase=false as “merge the upstream branch into the current branch.”
2) git config pull.rebase true
This means: when a pull needs reconciliation, use rebase. Git replays your local commits on top of the fetched upstream branch, which usually gives you a linear history. The resulting files can end up the same as with a merge, but the history is different because rebase rewrites your local commits into new ones. Git’s own docs warn that rebasing rewrites history and can be dangerous if that history has already been published for others to build on.
3) git config pull.ff only
This one is a bit different. It does not pick merge vs rebase for divergent histories. Instead it says: only allow the pull if it can be done as a fast-forward. If your branch has diverged from the remote, Git refuses and exits with an error instead of making a merge commit or rebasing automatically. In Git config terms, pull.ff=only is equivalent to —ff-only.
Ways To Pull and Sync
What these settings control
These settings tell Git what to do when you run git pull and your local branch and remote branch are not already in a simple fast-forward state.
Remember:
git pull=git fetch+ reconcile differences- If the remote is only ahead, Git can usually fast-forward
- If both local and remote have new commits, Git needs a policy
1) Merge on pull
git config pull.rebase false
What it does
Tells Git to use merge behavior when a pull needs reconciliation.
Important note
This does not mean Git will always create a merge commit.
- If a fast-forward is possible, Git will usually just fast-forward
- If the branches have diverged, Git will create a merge commit
Good fit when
- You want history to reflect real branch merges
- Your team is comfortable with merge commits
- You do not want rebasing to rewrite local commits
Resulting history
Before:
A---B---C origin/main
\
D---E main
After pull with merge:
A---B---C------M main
\ /
D------E
2) Rebase on pull
git config pull.rebase true
What it does
Tells Git to use rebase behavior when a pull needs reconciliation.
Git takes your local commits and replays them on top of the updated remote branch.
Why people use it
- Produces a cleaner, more linear history
- Avoids extra merge commits during everyday syncing
Important caution
Rebase rewrites commit history.
That is usually fine for your own local work, but it can cause trouble if those commits were already pushed and other people are building on them.
Good fit when
- You want a clean, linear history
- You are working on your own feature branch
- Your team is comfortable with rebasing
Resulting history
Before:
A---B---C origin/main
\
D---E main
After pull with rebase:
A---B---C---D'---E' main
3) Fast-forward only
git config pull.ff only
What it does
Tells Git to allow git pull only when the update can be done as a fast-forward.
If local and remote have both moved forward, Git stops and throws an error instead of choosing merge or rebase for you.
Why people use it
- Prevents surprise merge commits
- Prevents automatic history rewriting
- Forces an intentional decision when branches diverge
Good fit when
- You want conservative, explicit behavior
- You do not want
git pullmaking history decisions for you - You prefer to manually choose merge or rebase later
Resulting behavior
Before:
A---B---C origin/main
\
D---E main
After pull with ff-only:
Git refuses the pull because this is not a fast-forward.
Quick comparison
| Setting | What Git does on divergence | History style | Risk profile |
|---|---|---|---|
pull.rebase false | Merge | Branchy, explicit merges | Low risk, more merge commits |
pull.rebase true | Rebase | Cleaner, linear | Rewrites local commit history |
pull.ff only | Refuse | No automatic reconciliation | Safest, but more manual |
Rule of thumb
Use merge when
- You want the history to show actual integration points
- Your team already works comfortably with merge commits
Use rebase when
- You want a cleaner history
- You are syncing your own branch before pushing
Use ff-only when
- You want Git to be strict
- You want to decide manually whenever branches diverge
Common commands
Set for just the current repo:
git config pull.rebase false
git config pull.rebase true
git config pull.ff only
Set globally for all repos:
git config --global pull.rebase false
git config --global pull.rebase true
git config --global pull.ff only
Check your current settings:
git config --get pull.rebase
git config --get pull.ff
One subtle but important detail
pull.rebase false means use merge behavior when needed.
It does not mean always force a merge commit.
If you ever want to force merge commits even when a fast-forward is possible, that is a different setting and a different discussion.
Recommended default for most people
If you want the safest and least surprising behavior:
git config --global pull.ff only
That way, Git will not silently choose for you when histories diverge.
You can then explicitly choose:
git pull --rebase
or
git pull --no-rebase
when the situation calls for it.