Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How can you turn a stash into its own branch?

SHORT ANSWER

Run git stash branch new-name. Git creates the branch at the commit where you stashed, applies the stash there, and drops it, which avoids conflicts if the original branch has moved on.

Explain it simply

You parked half-finished work last week. main has moved a lot since, and popping the stash now produces conflicts.

git stash branch idea solves this. It checks out a new branch from the exact commit you were on when you stashed, applies the stash on top (guaranteed to fit), and deletes the stash on success. You can then continue the work as a normal branch and merge later. Pass a stash name to pick an older one.

Example

bash
git stash branch search-idea stash@{1}
git status     # work restored on branch search-idea
git commit -am "Continue search idea"

What to say in the interview

"git stash branch name creates a branch from the commit the stash was based on, applies the stash, and drops it. It sidesteps conflicts with newer commits and turns parked work into a proper branch."

#git#stash#branch

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.