The old value stays in the file on disk until you re-save your scene/prefab/scriptable object/etc. (I think Unity’s serialization system may also be able to keep those old values around internally until you restart the editor, but I’m not sure.)
When you start using source control you will see immediately that the addition of a public / serialized field produces a corresponding entry in the YAML of prefabs / scenes that contain that script.
This will only occur when you actually save each scene or prefab.
Same goes for removing such fields. Nothing about Unity would ever decide to go ransack your entire project (which could have millions of uses of that script) just to delete some stray data.
This also has data security implications. If you do a GameJam where you have a public string myPassword; field and for expediency you fill it out with JOSHUA, then realize "oh no, better make that field private and get it out of the keystore, it is on you to go make sure your seekrit data doesn’t still exist in prefabs / scenes.