I recently received a \"forced update\" warning from git on a repository which only I commit to. I haven\'t done any re-basing so I don\'t know why this happened. What I w
Git 2.23 (Q3 2019) illustrates when a "forced update" is detected, and propose the option to not show it.
See commit 3883c55, commit 377444b, commit cdbd70c (18 Jun 2019) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster -- in commit cde9a64, 09 Jul 2019)
fetch: add--[no-]show-forced-updatesargumentAfter updating a set of remove refs during a '
git fetch', we walk the commits in the new ref value and not in the old ref value to discover if the update was a forced update.This results in two things happening during the command:
The line including the ref update has an additional "(forced-update)" marker at the end.
The ref log for that remote branch includes a bit saying that update is a forced update.
For many situations, this forced-update message happens infrequently, or is a small bit of information among many ref updates.
Many users ignore these messages, but the calculation required here slows down their fetches significantly.
Keep in mind that they do not have the opportunity to calculate a commit-graph file containing the newly-fetched commits, so these comparisons can be very slow.Add a '
--[no-]show-forced-updates' option that allows a user to skip this calculation.
The only permanent result is dropping the forced-update bit in the reflog.Include a new
fetch.showForcedUpdatesconfig setting that allows this behavior without including the argument in every command.
The config setting is overridden by the command-line arguments.
That means the documentation now has:
fetch.showForcedUpdates:Set to
falseto enable--no-show-forced-updatesingit-fetchandgit-pullcommands.
Defaults to true.
--show-forced-updates:By default, Git checks if a branch is force-updated during fetch.
This can be disabled throughfetch.showForcedUpdates, but the--show-forced-updatesoption guarantees this check occurs.--no-show-forced-updates:By default, Git checks if a branch is force-updated during fetch.
Pass--no-show-forced-updatesor setfetch.showForcedUpdatestofalseto skip this check for performance reasons.If used during '
git-pull' the--ff-onlyoption will still check for forced updates before attempting a fast-forward update.
And:
fetch: warn about forced updates in branch listingThe
--[no-]show-forced-updatesoption in 'git fetch' can be confusing for some users, especially if it is enabled via config setting and not by argument.
Add advice to warn the user that the (forced update) messages were not listed.Additionally, warn users when the forced update check takes longer than ten seconds, and recommend that they disable the check.
These messages can be disabled by theadvice.fetchShowForcedUpdatesconfig setting.
The config advice documentation now includes:
fetchShowForcedUpdates:Advice shown when
git-fetchtakes a long time to calculate forced updates after ref updates, or to warn that the check is disabled.
Note, the test is fixed in Git 2.3.1/2.24 (Q4 2019)
See commit 814291c (30 Jul 2019) by SZEDER Gábor (szeder).
(Merged by Junio C Hamano -- gitster -- in commit 8aa76ab, 22 Aug 2019)
See commit decfe05, commit 7f005b0, commit 12b1826 (01 Aug 2019) by SZEDER Gábor (szeder).
(Merged by Junio C Hamano -- gitster -- in commit 77067b6, 22 Aug 2019)