How to prevent full recompile of UE with using UE source build when making minimal changes?

I’m using a UE source build with my project. Sometimes when I modify some C++ code in UE it seems to trigger a full recompile of UE for no apparent reason. Here’s an example file I recently modified which triggered a full rebuild: https://github.com/EpicGames/UnrealEngine/blob/072300df18a94f18077ca20a14224b5d99fee872/Engine/Plugins/Runtime/MassGameplay/Source/MassActors/Private/Translators/MassSceneComponentLocationTranslator.cpp#L1

In the Log.txt of the build I noticed some suspicious lines:

UnrealHeaderTool needs to run because UnrealHeaderTool timestamp (02/09/2024 15:53:04) is later than timestamp for module AutomationMessages (02/09/2024 14:51:53)
...
UnrealHeaderTool needs to run because UnrealHeaderTool timestamp (02/09/2024 15:53:04) is later than timestamp for module CoreUObject (02/09/2024 14:51:54)
...
UnrealEditor-NaniteDisplacedMesh.lib: Produced item "D:\repos\UnrealEngine\Engine\Plugins\Experimental\NaniteDisplacedMesh\Intermediate\Build\Win64\x64\UnrealEditor\Development\NaniteDisplacedMesh\UnrealEditor-NaniteDisplacedMesh.lib" was produced by outdated attributes.
...
UnrealEditor-SequencerCore.lib: Prerequisite Module.SequencerCore.cpp is produced by outdated action.
...
Deleting outdated item: D:\repos\UnrealEngine\Engine\Intermediate\Build\Win64\x64\UnrealEditor\Development\AudioMixer\UnrealEditor-AudioMixer.lib
...

There’s a ton of those “was produced by outdated attributes” and “produced by outdated action” and “Deleting outdated item” log lines. It seems to happen more often when I’m performing git commands such as switching branches and then switching back to another branch (but I didn’t build at all in between the branch switches).

Any idea how to prevent these full recompilations when they don’t seem necessary?