this post was submitted on 01 Mar 2024
19 points (100.0% liked)
Git
2909 readers
1 users here now
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Resources
Rules
- Follow programming.dev rules
- Be excellent to each other, no hostility towards users for any reason
- No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I've never really needed to use rebase, but my workflow is probably kinda weird:
git checkout -b new_feature_branch
, and so move my changes to a different branchgit reset head~10
meaning all 10 commits are reverted into staged changesgit push -f
the new commit back to origin (of feature branch)It works pretty well for me, but I was told its weird, and I should rebase instead
The benefit with rebase is if you want to have maybe 4 commits insteadd of 10. When reviewing a large pr, I find that it's helpfull if it's broken up into a couple of coherent commits so that I can review it commit by commit. It's easier to follow the logic of why something is being changed if it's associated with a specific commit.
Sometimes squashing the entire commit is the right choice, in which case you can do what you're doing or use some built in feature to do that.
You do you. People generally discourage rebase because it rewrites history but that's what you're doing anyway. You can achieve the same result with revase --interactive and following the instructions to squash all your in progress commits into a single commit. That way you don't have to figure out how many commits between your in progress and dev(for your reset command) as the rebase will handle it for you.