To cherry-pick dependent commits on macOS, first identify the prerequisite commit and apply it before the commit that relies on it. In Terminal, inspect the source branch’s history, confirm the destination branch has a clean working tree, then cherry-pick the selected commit IDs in dependency order. Git applies each commit’s change and creates a new commit on the branch you currently have checked out; it does not automatically determine which changes your destination needs. Git’s cherry-pick documentation

What order should dependent commits use?

Apply a prerequisite before its dependent change. For example, if commit a1b2c3 adds a function and commit d4e5f6 calls that function, pick a1b2c3 first and d4e5f6 second. If the second commit expects a file, interface, or behavior introduced by the first, reversing them may cause conflicts or leave the destination in a broken intermediate state.

Use the source branch’s parent-to-child order as your starting point. Git’s workflow guidance recommends splitting work into logical commits that are consistent and can work independently; real histories may not meet that ideal, so inspect what each selected commit changes and depends on. Cherry-picking copies commit changes individually, while merging brings changes at the branch level. If you need the whole branch and its history, consider whether a merge fits better than selecting commits one by one. Git workflows documentation

Inspect the history in Terminal

Open Terminal on your Mac, change to the repository folder, and check your current state. Replace the quoted path with your repository’s actual path; quoting allows spaces in folder names.

cd "/path/to/your/repository"
git status --short --branch
git log --graph --oneline --decorate --all

The first command changes Terminal’s working directory. git status shows the checked-out branch and any local changes. The graph view helps you see which commits are on the source branch and their order. macOS Terminal uses zsh by default, and the commands above use ordinary shell syntax supported there. Apple’s Terminal guide

If the needed branch is a remote tracking branch and its latest state is not present locally, fetch before inspecting it:

git fetch origin
git log --reverse --oneline origin/feature-name

Replace origin/feature-name with the actual remote branch name. The reverse option displays commits in oldest-first order. For a large history, narrow the log to the commits after a known common base, for example git log --reverse --oneline base-commit..origin/feature-name. Read the resulting subjects, then inspect candidate changes with git show COMMIT_ID. A commit range is convenient for review, but do not assume a range argument itself guarantees the custom dependency order you need: explicit commit IDs make the intended sequence clear.

Cherry-pick in prerequisite order

Before starting, commit or otherwise safely set aside local changes. The normal cherry-pick operation requires a clean working tree, and you should confirm the destination branch before applying anything. Replace the example IDs with the actual full or abbreviated commit IDs, ordered from prerequisite to dependent:

git switch destination-branch
git status --short --branch
git cherry-pick a1b2c3 d4e5f6

Git creates a new commit for each selected change in the supplied order. Check the output carefully: if a change was already included by another route, or the destination has diverged, Git may report an empty change or stop with a conflict. Afterward, inspect the resulting history and working tree with git log --oneline -n 5 and git status. Run the project’s relevant checks before relying on the result; a clean cherry-pick only means Git applied the changes, not that the feature behaves as intended.

If a commit conflicts

When a pick conflicts, Git pauses at that commit. Inspect the affected files and resolve each conflict by combining the intended source change with the destination branch’s current contents. Stage the resolved files with git add and continue the sequence:

git add "path/to/resolved-file"
git cherry-pick --continue

Use git cherry-pick --abort to cancel the current sequence and return to the state before it began. Use git cherry-pick --skip only when you have decided that the current commit’s change should be omitted; later commits may depend on it, so skipping can make those changes fail or lose their meaning. Git documents continue, skip, and abort as controls for an operation in progress. Git cherry-pick sequencer options

For a merge commit, pause before selecting it: Git requires a mainline parent choice because the merge has more than one parent. Likewise, if later commits cannot be understood without a long chain of earlier changes, selecting only a few may not produce a coherent result. Inspect the dependencies and choose the smallest complete sequence that preserves them.

Sources