git reset to remote and cherry-pick
sometimes i make commits to the wrong branch, ie: commits directly to one to main branches instead of creating a feature branch.
to get around that, i create a new branch with the mistaken commits — this is so i can still get the commits i make to cherry-pick later.
git checkout -b branch-with-good-commits
i reset the main branch to remote version:
git reset --hard origin/develop
the main develop
branch on my local should match what we have on remote branch
i create a new feature branch with this remote version.
i cherry-pick the good commits i originally wanted from branch-with-good-commits
onto the new feature branch
to get commit ids, from branch-with-good-commits
, run
git log
then cherry-pick
git cherry-pick -x <commit_id>
git cherry-pick is good to ensure that your PRs only include the features you were working on and not work from another feature.