You develop a new feature on the branch new-feature
. You have already
implemented the first part of a feature, when you are notified of a critical
bug that has to be fixed right away on the master
branch.
After the bug fix, you continue to work on the new feature. After you committed
the second part of the feature, you realize that you have done your commit on
the master
branch instead of the feature branch.
- Run
source setup.sh
(or.\setup.ps1
in PowerShell)
- Move the faulty commit from the
master
branch to thenew-feature
branch. - How would you also bring the bugfix to your feature branch?
git reset HEAD~1
to move the current branch one step back. This has the consequence of removing the newest commit from a branchgit stash
to temporarily save your changes so that you can switch branchesgit cherry-pick
to add changeset from commit on current branch