Yeke Yeke - 1 year ago 86
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download