To bring back one file from a stash on macOS, use git restore with the stash as its source and the file path as the target. This restores that file into your working tree while leaving the stash entry available. First identify the right stash and inspect its changes; then restore the specific path and review the result.

1. Open Terminal in the repository

Open Terminal from Spotlight or Finder’s Applications/Utilities folder, then change to the repository directory with cd. For example, type cd , drag the project folder into the Terminal window to insert its path, and press Return. Apple documents Terminal as macOS’s command-line interface; zsh is its default shell, though an administrator or user can configure another shell. Open or quit Terminal on Mac

Confirm you are in the intended repository and see the local changes before restoring anything:

git status --short

Restoring from a stash can replace the target file’s current working-tree contents, so save or commit any edits to that file that you need to keep. This operation is selective by path, but it is not a merge or a safety backup.

2. Find and inspect the stash

List available entries:

git stash list

Git labels the newest entry stash@{0}, the next stash@{1}, and so on. Choose the entry containing the version you want. If the descriptions are unclear, inspect a candidate as a patch:

git stash show --patch 'stash@{0}'

Replace stash@{0} with the entry you identified. Quoting the reference is useful in zsh because braces have shell syntax. Git documents stash show for inspecting a stash and stash apply for applying an entire entry; the command below instead selects a single path from the stash snapshot. git-stash documentation

3. Restore just the file

Run git restore with the stash reference as the source and the repository-relative path after --:

git restore --source='stash@{0}' -- 'src/config.json'

Replace src/config.json with the exact path you need, using forward slashes and spelling it relative to the repository root. The quotes also keep spaces and wildcard characters from being interpreted by the shell. The --source option selects a commit or tree as the content source; the pathspec limits which path Git restores. Since --staged is omitted, Git restores the working tree and leaves the index alone. git-restore documentation

Now review the change:

git status --short
git diff -- 'src/config.json'

The restored version is an unstaged working-tree change relative to the index in the usual case. If the file was staged before, compare the working-tree and index versions deliberately before staging or committing. The stash remains in the stash list because git restore reads from it without applying or removing the whole entry.

When this workflow needs adjustment

The path must exist in the stash’s working-tree snapshot. If it does not, Git may report that the pathspec did not match; check the patch and filename, including capitalization. A tracked path that is absent from the source tree may be removed to make the target match that tree, so be especially careful if the stash records a deletion. Git’s restore documentation describes this behavior. git-restore documentation

This recipe is for a file represented in the stash’s tracked working-tree snapshot. Stashes created with -u or -a can also contain untracked or ignored files, stored separately; git restore --source='stash@{0}' does not address that separate snapshot as though it were the main stash tree. Inspect such entries carefully and use Git’s documented stash inspection and recovery controls rather than assuming this command will retrieve them. git-stash documentation

If the goal is to apply selected lines rather than the whole file, git restore -p offers interactive hunk selection, but confirm the behavior and source for your installed Git version before relying on it. To restore both the staged and working-tree versions of a file, git restore supports both --staged and --worktree; this changes the index too, so use it only when that is intended. git-restore documentation

The practical sequence is: identify the stash, confirm the file in its contents, restore one repository-relative path from the chosen stash, and inspect the diff before continuing. That keeps the stash intact and limits the restore operation to the path you named.

Sources