Sub topic 11
Version history and handling conflicts
This chapter assumes you have already turned on iCloud Drive on your Mac, know how to use Finder, and understand that a file can exist as a cloud copy and as local copies on several devices. It covers three things. You will see how to go back to an earlier version of a file, what happens when two devices change the same file, and how to recover a file that was deleted.
Two different safety nets
iCloud Drive protects your work in two ways, and people often confuse them.
- Version history is a per-document timeline kept by macOS and by apps that support it. It lets you step back to an earlier state of one file.
- Deleted-file recovery is a service-level feature. It brings back files or folders that were removed from iCloud Drive.
Neither is a full backup. They do not cover files that were never synced, and they do not replace Time Machine or another backup.
How versions work on the Mac
Apps built on Apple's document system, such as Pages, Numbers, Keynote, TextEdit, and Preview, save snapshots of a document as you work. The system keeps these snapshots alongside the file. When a document is in iCloud Drive, edits made on another device are also recorded as versions.
To browse them:
- Open the document in a supporting app.
- Choose File > Revert To > Browse All Versions.
- The window changes to show the current document on the left and a stack of earlier versions on the right, each with a date and time.
- Select a version and click Restore to replace the current content. Alternatively, hold the Option key and click Restore a Copy to keep the current document and save the old state as a new file.
Restoring is itself recorded as a version, so you can undo a restore. Hold down Option, as above, when you are unsure. That way you compare the two files side by side before you commit.
Some limits apply:
- Versions come from the app, not from iCloud Drive itself. A plain
.txtfile edited in a tool that does not support versions has no timeline. A.zip, a.psd, or a database file has none either. - Older versions are pruned over time. The system keeps frequent snapshots for recent work and sparser ones for older work, so you cannot count on a specific old state existing.
- The timeline shown on the Mac depends on what has synced to that Mac. Check that the file has finished downloading before you browse its history.
Versions on other devices
On iPhone and iPad, version-aware apps expose a similar option. In Pages, for example, open the document, tap the More button, and choose Browse All Versions or the equivalent entry. The menu names change between app versions, so look for "versions" or "history" in the app's document menu.
What a sync conflict is
A conflict happens when two devices change the same file and neither change has reached the other yet. The typical cause is working offline:
- Your MacBook edits
budget.numberson a plane, with no network. - Your iPad edits the same file at home, and the change uploads.
- The MacBook lands and reconnects. It now holds changes based on a version that is no longer the latest.
iCloud Drive cannot merge arbitrary file contents, because it does not know the structure of a PDF or a spreadsheet. It has to pick a way to keep both sets of changes.
What you see when a conflict occurs
The behavior depends on the app.
- Apps with version support usually show a message that the document has a conflict, and let you choose which version to keep or open the version browser. In some cases the conflicting versions appear in Browse All Versions and you choose one there.
- Apps without version support end up with two files. One keeps the original name. The other gets a numbered suffix, such as
budget 2.numbers. Some apps or third-party tools add their own wording to the copy's name.
In both cases, the sync service avoids silently discarding either edit. The cost is that you must decide which file is the right one.
Resolving a duplicate-file conflict
- In Finder, open both files and compare them. Quick Look (select the file, press Space) is enough for many types.
- Copy anything you need from the loser into the winner. Keep the winner under the original name.
- Move the other file to the Trash.
- Let the sync finish. Check that the other devices now show only one file.
This step matters. If you delete the wrong copy before comparing, the content survives only in Recently Deleted (below), and only for a limited time.
Finding conflict copies from Terminal
If you keep large folders in iCloud Drive, a search for numbered duplicates helps you spot them. This example lists files whose names end in a space and a digit before the extension.
find "$HOME/Library/Mobile Documents/com~apple~CloudDocs" \
-type f -name "* [0-9].*" 2>/dev/nullNot every match is a conflict. Photos or exports that you numbered yourself will appear too, and conflicts may use a different pattern. Treat the output as a list of candidates and open each one before acting.
Reducing conflicts
Most conflicts are avoidable.
- Let a sync finish before closing the lid or switching devices. A file with an upload-in-progress icon has not reached the cloud. The status icons are covered in the chapter on reading the cloud and progress icons.
- Do not edit the same file on two devices at the same time unless you use an app built for collaboration. Apps such as Pages, Numbers, and Keynote support real-time collaboration on shared documents, which avoids the offline-fork problem.
- Avoid putting files that change constantly, like databases or build output, in synced folders. They produce frequent partial uploads and conflicts. The
.nosyncchapter later in this tutorial covers keeping such folders out. - Do not rename or move a folder on one device while another device is still editing files inside it.
Recovering deleted files
Deleting a file in iCloud Drive on a Mac moves it to the Trash, like any other file. Deleting it on one device removes it from the others after sync, because iCloud Drive mirrors changes. A deletion is therefore as widespread as an edit.
You have three recovery routes, from easiest to broadest:
- The Mac Trash. Open the Trash in the Dock. Select the item and choose File > Put Back, or drag it out. This works only if you have not emptied the Trash.
- Recently Deleted on iCloud.com. Sign in at iCloud.com, open Drive, and choose Recently Deleted. Select the files and click Recover. Items remain there for 30 days after deletion.
- Data Recovery on iCloud.com. In your account settings on iCloud.com, the Data Recovery section lets you restore files, and also contacts, calendars, and bookmarks, from a recent snapshot. Apple states a limited window (about 30 days), and restoring files by this route can bring back files that were permanently deleted. Check the current Apple Support page for the exact conditions, because they change.
Consider the difference between these routes:
| Need | Best route | Limit |
|---|---|---|
| Undo changes inside one document | Browse All Versions | Only for version-aware apps; old versions are pruned |
| Get back a file you just trashed | Trash, then Put Back | Gone once the Trash is emptied |
| Get back a file deleted days ago | iCloud.com Recently Deleted | About 30 days |
| Get back files deleted by a mistake or bulk removal | iCloud.com Data Recovery | Time-limited; check Apple's page |
| Recover from a lost or corrupted Mac | Time Machine or other backup | Only what the backup captured |
Checking your work before and after
Some habits make recovery much more likely to succeed.
- Before a risky edit to an important file, duplicate it in Finder (File > Duplicate). A duplicate is a separate file with its own history.
- Before you resolve a conflict, make sure all devices have finished syncing. Otherwise the file you are comparing may still be missing changes.
- After restoring, open the file on a second device and confirm it shows the restored content.
Exercise
You edited notes.txt on your MacBook while offline, and a colleague edited the same file on an iPad that was online. After you reconnect, you find notes.txt and notes 2.txt in Finder. Describe what you should do before deleting either file, and where you could look if you delete the wrong one.
Show answer
Open both files, for example with Quick Look, and compare their contents. Copy any changes you need from one into the other, and keep the merged file under the original name notes.txt. Let sync finish, then move the leftover copy to the Trash. If you delete the wrong one, first check the Mac Trash and use Put Back. If the Trash was emptied, sign in at iCloud.com, open Drive, and look in Recently Deleted, which keeps items for about 30 days. A plain text file has no version history of its own, so these routes are your only option.
Exercise
Why does Browse All Versions not help with a .zip archive stored in iCloud Drive?
Show answer
Version history is provided by apps that use Apple's document versioning, such as Pages, TextEdit, and Preview. A .zip archive is not edited in such an app, so no snapshot timeline is kept for it. To protect it, duplicate it before changes, or rely on Recently Deleted, Data Recovery, or a Time Machine backup.