From macOS help:
If you have two Mac computers with FireWire or Thunderbolt ports, you can connect them so that one of them appears as an external hard disk on the other. This is called target disk mode.
Connect the two computers with a FireWire or Thunderbolt cable.
On the Mac you want to use as the disk in target disk mode, do one of the following:
If the computer is off, start it up while holding down the T key.
If the computer is on, choose Apple menu > System Preferences, click Startup Disk, then click Target Disk Mode.
When the computer has started up, a disk icon appears on the desktop of the other computer.
Transfer files by dragging them to and from the disk.
Eject the disk by dragging its icon to the Trash. While you drag, the Trash icon changes to an Eject icon.
On the Mac you used as a disk, push the power button to shut it down, then disconnect the cable.
The Apple Target Disk Mode support article is here.