Create branch from current working tree and reset to HEAD

放肆的年华 提交于 2019-12-03 23:53:16

So, create a working branch:

git checkout -b working_branch

either commit or stash your changes

git add <files>
git commit -m "message"

OR

git stash

Go back to master

git checkout master
git reset HEAD

If you haven't yet made a commit then you don't need to move master, it's already at the current HEAD. You can just checkout a new branch with checkout -b, it doesn't need your working tree to be clean.

E.g.

git checkout -b newtopic

You are now on newtopic and can commit your working tree changes here. master doesn't need to move.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!