05-10-2021

Free up storage space on your Mac Save space by storing your content in iCloud or using built-in tools to find and remove large or unneeded files. The Optimized Storage features of your Mac help you save storage space by storing your content in iCloud and making it available on demand. Save space on your Mac by storing your content in iCloud, using built-in tools to find and remove large files, or manually deleting apps, files, and more.

Clean up your dev environment you filthy animal!

Ilove cleaning software? PLZ! Remove duplicates, find old OS cruft etc. But it never cleans a development machine as I can.

Sure, for general maintenance, nothing beats CleanMyMac. But once a year, developers should run through a few manual commands, because auto-cleaners won’t know how to take care of a developer machine.

Before we start, let’s look at how much “Free Space” you’re starting with:

Mine is reporting 132.2 GB before cleaning. Time to get started!

Mac Homebrew Users

This one usually shaves off hundreds of megs of data. Update, upgrade, and then clean up those files you’re not going to use.

Update then remove old formulae and their folders:

You might have used brew prune in the past, but that has been deprecated. Cleanup handles this for you!

General Brew Maintenance

Mac

Brew is a complicated system, and no one knows it better than the maintainers. So you can run brew doctor and get some additional chores you could take care of to have it run properly.

Git Users

Git is great, but it’s not hard to leave a bunch of merged branches laying around on your local machine! Those branches aren’t useful anymore, and sometimes make naming conflicts for future branches.

You can remove all the merged branches from a single project with this command:

WOW, what a mouthful for only one project! Let’s make it worse. ?

This code will CD into all folders in the current working directory, and then run the command to clean merged branches for each!

JavaScript Developers

Delete OLD `node_modules` embedded in projects

The following command finds all node_modules folders older than 120 days and removes them. This does mean you will have to npm i or yarn again in those older projects. This is usually a huge cleanup!

Removes all node_modules folders older than 4 months:

If you’re feeling quite aggressive, you can just clear out ALL node_modules folders and re-install as needed, by removing the mtime flag.

Removes all node_modules folders:

Remove old versions of Node

Remove old versions of Node. This varies depending on your Node manager. I use ’n’ so it’s easy for me. Consult uninstall for your specific version manager.

Using n?
List all versions of node + your installed ones with n ls and then remove any with n rm <version>.
Using nvm?
List your installed versions with nvm ls and then remove any with nvm uninstall <version>.
Using asdf?
List your installed versions with asdf list nodejs and then remove any with asdf uninstall nodejs <version>.

Ruby Developers

Clean up old versions of Gems with the cleanup command. If you’re worried, you can see the results first with “dryrun”.

Then when you are confident, you can remove the “dryrun” param and run it for real.

Remove old versions of Ruby

This depends specifically on your Ruby version manager. We’ll do two popular versions to help you out.

Using rbenv?
List your installed versions with rbenv versions and then remove any with rbenv uninstall <version>.
Using rvm?
List your installed versions with rvm list and then remove any with rvm uninstall <version>.

Xcode Developers

Xcode loves to cache things all over your machine, and some of these are hundreds of megs. Time to clean them up, and if you need to rebuild them again, no worries!

Clean up CocoaPod caches:

Delete old Xcode Simulators:

Clean up various archives, logs, and derived data folders:

Check out your connected device info in ~/Library/Developer/Xcode/iOS Device Logs/ and delete anything for old iOS devices you’ve connected.

Free Up Mac Space

Docker

You can remove all volumes not used by at least one container. Because… why would you want those?!

This might be huge or it might remove nothing. Worth a run right!?

Remove unused local volumes

RESULTS?!

Don’t forget to empty your trash and check on how we did!

Free Up Mac Space
30 GIGS! pulled off my machine! How about you?

Your success is probably vastly different, but I’d love to know. Comment or tweet at me your results, and any other developer spots you recommend we clean! I’ll be happy to add your advice to the article.

Gant Laborde is Chief Technology Strategist at Infinite Red, published author, adjunct professor, worldwide public speaker, and a mad scientist in training. Clap/follow/tweet or visit him at a conference.

5 Things that Suck about Remote Work
The Pitfalls of Remote Work + Proposed Solutionsshift.infinite.redReact Native vs. Native
Should I learn React Native or Native?shift.infinite.red

The Optimized Storage features of your Mac help you save storage space by storing your content in iCloud and making it available on demand:

  • When storage space is needed, files, photos, movies, email attachments, and other files that you seldom use are stored in iCloud automatically.
  • Each file stays right where you last saved it, and downloads when you open it.
  • Files that you’ve used recently remain on your Mac, along with optimized versions of your photos.

If you haven't yet upgraded to macOS Sierra or later, learn about other ways to free up storage space.

Find out how much storage is available on your Mac

Choose Apple menu  > About This Mac, then click Storage. Each segment of the bar is an estimate of the storage space used by a category of files. Move your pointer over each segment for more detail.

Click the Manage button to open the Storage Management window, pictured below.

Manage storage on your Mac

The Storage Management window offers recommendations for optimizing your storage. If some recommendations are already turned on, you will see fewer recommendations.

Free up mac disk space

Store in iCloud

Click the Store in iCloud button, then choose from these options:

  • Desktop and Documents. Store all files from these two locations in iCloud Drive. When storage space is needed, only the files you recently opened are kept on your Mac, so that you can easily work offline. Files stored only in iCloud show a download icon , which you can double-click to download the original file. Learn more about this feature.
  • Photos. Store all original, full-resolution photos and videos in iCloud Photos. When storage space is needed, only space-saving (optimized) versions of photos are kept on your Mac. To download the original photo or video, just open it.
  • Messages. Store all messages and attachments in iCloud. When storage space is needed, only the messages and attachments you recently opened are kept on your Mac. Learn more about Messages in iCloud.

Storing files in iCloud uses the storage space in your iCloud storage plan. If you reach or exceed your iCloud storage limit, you can either buy more iCloud storage or make more iCloud storage available. iCloud storage starts at 50GB for $0.99 (USD) a month, and you can purchase additional storage directly from your Apple device. Learn more about prices in your region.

Optimize Storage

Click the Optimize button to save space by automatically removing watched movies and TV shows. When storage space is needed, movies or TV shows that you purchased from Apple and already watched are removed from your Mac. Click the download icon next to a movie or TV show to download it again.

Your Mac will also save space by keeping only recent email attachments on this Mac when storage space is needed. You can manually download any attachments at any time by opening the email or attachment, or saving the attachment to your Mac.

Optimizing storage for movies, TV shows, and email attachments doesn't require iCloud storage space.

Empty Trash Automatically

Empty Trash Automatically permanently deletes files that have been in the Trash for more than 30 days.

Reduce Clutter

Reduce Clutter helps you identify large files and files you might no longer need. Click the Review Files button, then choose any of the file categories in the sidebar, such as Applications, Documents, Music Creation, or Trash.

You can delete the files in some categories directly from this window. Other categories show the total storage space used by the files in each app. You can then open the app and decide whether to delete files from within it.

Learn how to redownload apps, music, movies, TV shows, and books.


Where to find the settings for each feature

The button for each recommendation in the Storage Management window affects one or more settings in other apps. You can also control those settings directly within each app.

  • If you're using macOS Catalina or later, choose Apple menu  > System Preferences, click Apple ID, then select iCloud in the sidebar: Store in iCloud turns on the Optimize Mac Storage setting on the right. To turn off iCloud Drive entirely, deselect iCloud Drive.
  • If you're using macOS Mojave or earlier, choose Apple menu > System Preferences, click iCloud, then click Options next to iCloud Drive. Store in iCloud turns on the Desktop & Documents Folders and Optimize Mac Storage settings.
  • In Photos, choose Photos > Preferences, then click iCloud. Store in iCloud selects iCloud Photos and Optimize Mac Storage.
  • In Messages, choose Messages > Preferences, then click iMessage. Store in iCloud selects Enable Messages in iCloud.
  • If you're using macOS Catalina or later, open the Apple TV app, choose TV > Preferences from the menu bar, then click Files. Optimize Storage selects “Automatically delete watched movies and TV shows.”
  • In you're using macOS Mojave or earlier, open iTunes, choose iTunes > Preferences from the menu bar, then click Advanced. Optimize Storage selects “Automatically delete watched movies and TV shows.”
  • In Mail, choose Mail > Preferences from the menu bar, then click Accounts. In the Account Information section on the right, Optimize Storage sets the Download Attachments menu to either Recent or None.

Empty Trash Automatically: From the Finder, choose Finder > Preferences, then click Advanced. Empty Trash Automatically selects “Remove items from the Trash after 30 days.”

Other ways that macOS helps automatically save space

With macOS Sierra or later, your Mac automatically takes these additional steps to save storage space:

  • Detects duplicate downloads in Safari, keeping only the most recent version of the download
  • Reminds you to delete used app installers
  • Removes old fonts, languages, and dictionaries that aren't being used
  • Clears caches, logs, and other unnecessary data when storage space is needed

How to free up storage space manually

Even without using the Optimized Storage features described in this article, you can take other steps to make more storage space available:

  • Music, movies, and other media can use a lot of storage space. Learn how to delete music, movies, and TV shows from your device.
  • Delete other files that you no longer need by moving them to the Trash, then emptying the Trash. The Downloads folder is good place to look for files that you might no longer need.
  • Move files to an external storage device.
  • Compress files.
  • Delete unneeded email: In the Mail app, choose Mailbox > Erase Junk Mail. If you no longer need the email in your Trash mailbox, choose Mailbox > Erase Deleted Items.

What Is Other In Mac Storage

Learn more

Free Up Space On Mac

  • The Storage pane of About This Mac is the best way to determine the amount of storage space available on your Mac. Disk Utility and other apps might show storage categories such as Not Mounted, VM, Recovery, Other Volumes, Other, Free, or Purgeable. Don't rely on these categories to understand how to free up storage space or how much storage space is available for your data.
  • When you duplicate a file on an APFS-formatted volume, that file doesn't use additional storage space on the volume. Deleting a duplicate file frees up only the space required by any data you might have added to the duplicate. If you no longer need any copies of the file, you can recover all of the storage space by deleting both the duplicate and the original file.
  • If you're using a pro app and Optimize Mac Storage, learn how to make sure that your projects are always on your Mac and able to access their files.