如何补救意外地提交到主分支而不是我的功能分支 [英] How to remedy for accidently making a commit into the master branch instead of my feature branch
问题描述
在本地,我忘了从主分支创建一个功能分支,然后将更改提交到主分支。
如何更正错误,以便将提交从主分支中删除,并且变成新的功能分支?
谢谢。 解释: Locally, I forgot to create a feature branch from the master branch, and then made a commit of my changes into the master branch. How can i correct the mistake, so that the commit is removed from the master branch, and is made into a new feature branch? Thanks. Explanation:
这篇关于如何补救意外地提交到主分支而不是我的功能分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git checkout master
git checkout -b my-feature-branch
git checkout master
git reset --hard HEAD〜1
git checkout my-feature-branch
master
分支。
master
分支。
master
分支到最后一个之前的提交。
git checkout master
git checkout -b my-feature-branch
git checkout master
git reset --hard HEAD~1
git checkout my-feature-branch
master
branch.master
branch.master
branch to the commit before the last one.