A script file has been moved outside of the Unity editor and I need to relink it to a prefab.
The editor detects the file is moved, and gives a warning like this:

And if I open it I can see the script is grayed out. It has successfully found where the script is now – double-clicking opens that script.

I don’t see anyway to update, or lock-in, this change however. The above control is disabled, and there doesn’t appear to be anything to save. If I modify something else in the prefab, then attempt to save, I get an error about a missing script.
How can I get the editor to update and save with the link to the found script?
Perhaps this is related. When I look at the script file in the editor it says it can’t find the MonoBehavior. Other than having been moved, the file hasn’t changed, and the name still looks correct.

I fixed this by right-clicking on the top-level “Scripts” folder in my project and choosing “Reimport”.
In case you ever run into this again:
If you set the inspector to Debug, you can drag in the script. This can often fix this whilst keeping any serialized data (i.e. variables you set via the inspector) intact.
Thanks. I noticed one of my scripts lost its settings, but the other ones did not.
tl;dr: it’s the .meta file
The general process explaining this loss is here:
Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:
https://discussions.unity.com/t/836322/2
https://discussions.unity.com/t/815173/7
https://discussions.unity.com/t/815173/9
EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.
When Renaming: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don’t do that. Instead:
- close Visual Studio (important!)
- rename the file(s) in Unity
- in Unity do Assets → Open C# Project to reopen Visual Studio
- now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!
If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.