Yeke Yeke - 5 months ago 50
Git Question

git stash and branch previous working version?

I created a

branch A
, made some changes and as "everything was ok" I
Then I continued working in A, but everything has become quite messy, however I have a good intuition in that mess (maybe it's not lol).

Is there a form to
the mess, create a new
branch B
starting from the "everything was ok"
in branch A
and continue working in
branch B
? I'm thinking in coming back to the mess in
branch A
later and hopefully merge.


If you want to create a new branch, there's no need to stash. You can create a new branch starting from the latest good commit. While in branch A, get the hash of the latest good commit, by using git log. Then run:

git checkout <branchA_hash> -b branchB

This will create a new branch called branchB, updated at that commit you've chosen.

In any moment you can then come back to your messy branch A by just checking it out again.