I have seen that most of the time the answer to the questions "How can I merge the primary APFS partition with another empty APFS partition?"Or"How do we delete the BOOTCAMP partition and add the volume of an existing APFS container?"Is the full reinstallation of macOS with HDD formatting.
Well, there are other, simpler solutions that do not require a system reset that could take several hours with custom applications and settings.
If you have used it Boot Camp Assistant to install a parallel operating system (Windows7, Windows 10, etc.), a new partition called BOOTCAMP appeared on MacOS. This partition often maintains the parallel operating system, which is created during the installation process from the primary partition space. Master. If you want to quit the parallel operating system installed on your Mac, MacBook and you want the space occupied by the BOOTCAMP partition to be deleted and added to the macOS partition, then you have to follow a simple tutorial that takes a lot less time than to reinstall the entire macOS operating system.
How to delete a parity and how to add free space to an APFS partition - Resize APFS Container
In our scenario we have to deal with a hard of 250 GB divided into a partition (container) APFS the main 199 GB (Container Apple_APFS disk1 – disk0s2) and one that we had BOOTCAMP by 50.7 GB (Apple_HFS Untitled - disk0s3) to be deleted and its 50.7 GB space added to the main partition. At the end we will get one 250GB partition.
1. We delete the disk0s3 volume without formatting it. In this way we will get one free space on the disk that we can later add to disk0s2.
sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3
2. We give the main APFS partition space left on the disk after the above operation.
diskutil apfs resizeContainer disk0s2 0
Finally, we get a single "macOS" / disk0s2 by 250 GB.
If you have multiple partitions you need to be very careful what you delete. Correctly identify the name of the partition you want to delete, then execute the command line. To view all available partitions and volumes, run in Port command: disktil list.
This tutorial is done on a beta version of a macOS Mojave, but it is compatible MacOS High Sierra.Merge APFS Containers in single partition / macOS High Sierra or Mojave