Back up your data
Sign out of iCloud
Sign out of iMessage
Sign out of FaceTime
Sign out of other accounts and apps
Restart your MacBook in Recovery mode
On Apple silicon MacBook, shut down, then press and hold the power button until startup options appear
On Intel MacBook, restart and hold Command-R
Open Disk Utility
Select your startup disk
Erase the disk
Quit Disk Utility
Choose Reinstall macOS
Follow the on-screen instructions
Set up the MacBook as new or restore from backup
