Okay, one more... Ever commit something only to immediately realize that you're on the wrong branch? Use "git move <branch>".
Interesting… I typically commit, cut a branch, reset current. Find it doesn't disrupt my workflow and avoids complex commands like stash.
That approach requires three checkouts if you want to end up on new branch, hence the stashing.
You need to collect these in a blog post or something, so they don't get lost in the depths of Twitter.
Agreed. They're in my .gitconfig so they're there whenever I get around to blogging again... I've got quite a backlog.
I would have thought cherry-pick then reset head would be a *lot* cleaner....
It's pick your poison, really. Here's the same end result using cherry-pick:
I personally just "git checkout -b NEWBRANCH" then go back to the previous branch and reset to the last good commit
So... three checkouts by the time you get back to the new branch to continue working?
Later in the thread we evolved it to a branch, rebase onto, checkout three step, though works only for existing branches.
Not so much. Here's the same end result using cherry-pick:
This feels good. Need to make this a lib or something.
It could use a graceful failure when omitting the new branch name, also should confirm branch creation if it doesn't exist. But, yeah. :)
If junio can trust it, why not try to push it to the project instead? If junio can trust it.
United States Tren
- 1. #warmertogether N/A
- 2. $BARRON 2,090 posts
- 3. Harvey Weinstein 3,046 posts
- 4. Diane Ladd 3,372 posts
- 5. Ben Shapiro 27.3K posts
- 6. $PLTR 16.7K posts
- 7. Laura Dern 1,619 posts
- 8. Gold's Gym 49.1K posts
- 9. #NXXT 2,505 posts
- 10. #maddiekowalski 4,098 posts
- 11. #CAVoteYesProp50 5,883 posts
- 12. Cardinals 11.8K posts
- 13. iOS 26.1 3,186 posts
- 14. Standout 7,745 posts
- 15. University of Virginia 1,843 posts
- 16. McBride 2,933 posts
- 17. $HIMS 6,053 posts
- 18. Ndiaye 9,737 posts
- 19. #BestStockToBuy 1,117 posts
- 20. Shannon Library 1,852 posts
Something went wrong.
Something went wrong.