Moving commits from main to feature-branch

For when I forget to change into a feature-branch before committing a bunch of changes next time, here's how I fixed it this time:


git checkout -b further-refinement

Create the feature branch I should've created before I started to mess around with code!


git checkout -

Return to the main branch.


git log -10 --oneline

Show the 10 latest commits from the main branch, each on a single line.


👀 find the last commit you'd like to keep on main (moving the rest to your feature branch)


git reset --hard <commit-id>

Remove the commits you'd like to move from the main branch (they'll still be in your feature branch).


git checkout -

Return to your feature branch.


git push --set-upstream origin further-refinement

Push it (to GitHub).


gh pr create --fill

Create a PR via the GitHub command line tools (or look at the /pulls list in GitHub and create from there)


Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints