harish
harish

Reputation: 1924

Is there a way to stash working tree changes and the latest commit in Git

I have a cherry-picked commit and local working tree changes on top of it. I want stash these both so that I can switch HEAD to parent commit temporarily and then return it back to previous state. Is it possible to do this without creating a branch?

Upvotes: 0

Views: 40

Answers (1)

mkrieger1
mkrieger1

Reputation: 23142

You don't necessarily need to create a new branch (although it's cheap and I wouldn't hesitate to create one).

The quickest way I can think of is the following (assuming your branch is called master):

$ git stash
$ git checkout HEAD^

Do stuff on parent commit...

Then return:

$ git checkout master
$ git stash pop

Upvotes: 1

Related Questions