我开始着手修复我的主分支上的一个小错误。然而,它已经失去了控制,以至于我希望当初创建一个单独的分支来进行开发。
所以现在我想做的是:
我怎么能这么做?
If you haven't been committing anything yet, you're already in the right position.
git checkout -b edge
git add
edge
master
git checkout
git merge edge
To add to JB's answer, if you have already started to make a few commits on master for what ended up as being a "edge" effort, you could:
git stash git checkout -b edge master git branch -f master SHA1_before_your_commits git stash apply
If you are trying to move the work from master to a branch that already exists, but is behind master, git won't let you switch to the other branch. In this case, do this:
git stash git checkout oldBranch git merge master git checkout master git stash apply git checkout oldBranch