git stash changes apply to new branch?

Viewed 289273

I was working on master branch, made some changes and then stashed them. Now, my master is at HEAD.

But now, I want to retrieve these changes but to a new branch which branches from the HEAD version of the master branch.

How do i do this ?

3 Answers

If you have some changes on your workspace and you want to stash them into a new branch use this command:

git stash branch branchName

It will make:

  1. a new branch (starting from the commit at which the stash was originally created)
  2. move changes to this branch
  3. and remove latest stash (Like: git stash pop)

After running this command, you will want to git add the changes and to commit them.

Related