Note: Earlier we taught "git pull
"(man) to warn when the user does not say the histories need to be merged, rebased or accepts only fast-forwarding, but the warning triggered for those who have set the pull.ff
configuration variable.
This is no longer the case (meaning: no more warning) with Git 2.29 (Q4 2020).
See commit 54200ce (24 Sep 2020) by Alex Henrie (alexhenrie
).
(Merged by Junio C Hamano -- gitster
-- in commit 299deea, 29 Sep 2020)
pull
: don't warn if pull.ff
has been set
Signed-off-by: Alex Henrie
A user who understands enough to set pull.ff
does not need additional instructions.
Before Git 2.31 (Q1 2021), when a user does not tell "git pull
"(man) to use rebase or merge, the command gives a loud message telling a user to choose between rebase or merge but creates a merge anyway, forcing users who would want to rebase to redo the operation.
Fix an early part of this problem by tightening the condition to give the message--- there is no reason to stop or force the user to choose between rebase or merge if the history fast-forwards.
See commit 7539fdc, commit b044db9 (14 Dec 2020) by Junio C Hamano (gitster
).
See commit c525de3, commit 278f4be, commit 77a7ec6 (12 Dec 2020) by Felipe Contreras (felipec
).
(Merged by Junio C Hamano -- gitster
-- in commit d3fa84d, 06 Jan 2021)
pull
: display default warning only when non-ff
Suggestions-by: Junio C Hamano
Signed-off-by: Felipe Contreras
There's no need to display the annoying warning on every pull... only the ones that are not fast-forward.
The current warning tests still pass, but not because of the arguments or the configuration, but because they are all fast-forward.
We need to test non-fast-forward situations now.
The warning changes with With 2.34 (Q4 2021): "git pull
"(man) had various corner cases that were not well thought out around its --rebase
backend, e.g. "git pull --ff-only
"(man) did not stop but went ahead and rebased when the history on other side is not a descendant of our history.
See also below: Git 2.34 does not yet fix everything.
See commit 6f843a3, commit 359ff69, commit 031e2f7, commit adc27d6, commit e4dc25e (22 Jul 2021), and commit 1d25e5b, commit be19c5c (21 Jul 2021) by Elijah Newren (newren
).
See commit 3d5fc24 (21 Jul 2021) by Alex Henrie (alexhenrie
).
(Merged by Junio C Hamano -- gitster
-- in commit 7d0daf3, 30 Aug 2021)
pull
: abort by default when fast-forwarding is not possible
Initial-patch-by: Alex Henrie
Signed-off-by: Elijah Newren
We have for some time shown a long warning when the user does not specify how to reconcile divergent branches with git pull
.
Make it an error now.
git pull
now includes in its man page:
Incorporates changes from a remote repository into the current branch.
- If the current branch is behind the remote, then by default it will
fast-forward the current branch to match the remote.
- If the current branch and the remote have diverged, the user needs to specify how to reconcile the divergent branches with
--no-ff
, --ff
, or --rebase
(or the corresponding configuration options in pull.ff
or pull.rebase
).
More precisely, git pull
runs git fetch
with the given parameters and then depending on configuration options or command line flags, will call either git merge
or git rebase
to reconcile diverging branches.
So: instead of seeing (before Git 2.33.1):
Pulling without specifying how to reconcile divergent branches is discouraged.
You can squelch this message by running one of the following commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
You will see:
You have divergent branches and need to specify how to reconcile them.
You can do so by running one of the following commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
Meaning, if you don't run one of those commands, you will get a fatal error:
fatal: Need to specify how to reconcile divergent branches.
Update for Git 2.35 (Q1 2022)
Ark Kun reports:
Git 2.34 is still broken. It refuses to pull a remote branch which is an ancestor of the current branch head.
git fails instead of doing nothing.
VSCode has sync feature that does pull and push.
The feature has been broken for months because GIT changed the behavior.
Fortunately this issue is finally fixed in GIT master
That was reported/discussed in this Git mailing thread, and a fix is in progress (git commit ea1954a)
Before Git 2.35 (Q1 2022), "git pull
"(man) with any strategy when the other side is behind us should succeed as it is a no-op, but doesn't.
See commit ea1954a (17 Nov 2021) by Erwin Villejo (erwinv
).
(Merged by Junio C Hamano -- gitster
-- in commit 0f2140f, 21 Nov 2021)
pull
: should be noop when already-up-to-date
Signed-off-by: Erwin Villejo
The already-up-to-date pull bug was fixed for --ff-only
but it did not include the case where --ff
or --ff-only
are not specified.
This updates the --ff-only
fix to include the case where --ff
or --ff-only
are not specified in command line flags or config.
With Git 2.41 (Q2 2023), after "git pull
"(man) that is configured with pull.rebase=false merge.ff=only
fails due to our end having our own development, give advice messages to get out of the "Not possible to fast-forward
" state.
See commit 765071a (07 Mar 2023) by Felipe Contreras (felipec
).
(Merged by Junio C Hamano -- gitster
-- in commit 9de14c7, 19 Mar 2023)
advice
: add diverging advice for novices
Signed-off-by: Felipe Contreras
Acked-by: Taylor Blau
The user might not necessarily know why ff only was configured, maybe an admin did it, or the installer (Git for Windows), or perhaps they just followed some online advice.
This can happen not only on pull.ff=only
, but merge.ff=only
too.
Even worse if the user has configured pull.rebase=false
and merge.ff=only
, because in those cases a diverging merge will constantly keep failing.
There's no trivial way to get out of this other than git merge --no-ff
(man).
Let's not assume our users are experts in git who completely understand all their configurations.
git config
now includes in its man page:
diverging
Advice shown when a fast-forward is not possible.
So, instead of just seeing:
Not possible to fast-forward, aborting.
You will see:
Diverging branches can't be fast-forwarded, you need to either:
git merge --no-ff
or:
git rebase
Not possible to fast-forward, aborting.
git push
in the terminal, my code was pushed without a problem. – Cunggit push
in the terminal without any issues. If someone faces this problem in the VS Code, I recommend trying this solution. – Pastelgit pull --no-ff
– Huddle