git branching - how to make current master a branch and then revert master back to previous version?

前端 未结 2 1577
青春惊慌失措
青春惊慌失措 2021-02-10 15:58

This is probably quite simple but I\'m currently a git noob and haven\'t quite got my head round the git branching model yet.

Suppose I currently have no branches other

2条回答
  •  长情又很酷
    2021-02-10 16:36

    you are almost done.

    Assume you have made a commit on your development files. Then..

    git branch experimental_stuff

    git reset --hard HEAD^ (go back one previous commit of your master branch to continue your development)

    Assume you have not made a commit on your development files. Then.. you need to save your current changes to a temporary directory

    git stash

    git checkout -b experimental_stuff (create and change branch to experiental_stuff)

    git stash pop (populate the temporary directory into experimental branch)

    git checkout master (return back to master, and no need to go back the previous commit this time as you don't have that commit)

提交回复
热议问题