Sometimes I want to update one package, for example a server, and nothing else. A plain install would also install it if it is missing, which is not what I mean.
The apt-get manual describes --only-upgrade like this: do not install new packages; used together with install, it installs upgrades for already installed packages only and ignores requests to install new packages. So the command touches only what you already have:
sudo apt-get install --only-upgrade nginx
If nginx is installed and a newer version is available, it gets upgraded. If nginx is not installed, nothing is installed, which is a nice safety net against a typo in the package name that happens to match another package. You can list several names, and the manual says package names are matched as regular expression, glob or exact name, so I would test a pattern with a simulation first:
apt-get -s install --only-upgrade 'php8*'
The -s flag only simulates the run. Look at the output to see which packages would be upgraded before you run it for real.
There is a sibling option with the opposite meaning, --no-upgrade. With install, it prevents packages named on the command line from being upgraded if they are already installed, which is handy when you want to add something and leave the rest as it is.
The caveat is that --only-upgrade still follows dependencies. The manual says it ignores requests to install new packages, but a newer version of the package may want new or changed dependencies, and apt works that out like it always does. The simulation shows this.
For a package I never want to move, apt-mark hold is the permanent version of this idea.
Further reading: apt-get(8): –only-upgrade and –no-upgrade