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
git checkout master
git checkout -b my-feature-branch
git checkout master
git reset --hard HEAD~1
git checkout my-feature-branch
Explanation:
master
branch.master
branch.master
branch to the commit before the last one.Let's consider the situation
before committing
... -- A ^ | master
after commit
... -- A -- B ^ | master
To resolve situation, you need to perform the following steps:
method 1
git branch -m feature
... -- A -- B ^ | feature
git checkout -b master A
... -- A -- B ^ ^ | | | feature | master
method 2
git checkout -b feature
... -- A -- B ^ | feature * master
git checkout master
... -- A -- B ^ | feature master *
git reset --hard HEAD~1
... -- A -- B ^ ^ | | | feature | master