Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I can give you an example of when I am glad I rebased

I think the question was about situations where you were glad to rebase, when you could have merged instead



They kind of spoke to it. Rebasing to bring in changes from main to a feature branch which is a bit longer running keeps all your changes together.

All the commits for your feature get popped on top the commits you brought in from main. When you are putting together your PR you can more easily squash your commits together and fix up your commit history before putting it out for review.

It is a preference thing for sure but I fall into the atomic, self contained, commits camp and rebase workflows make that much cleaner in my opinion. I have worked with both on large teams and I like rebase more but each have their own tradeoffs


You can bring in changes and address conflicts early with merge too, I believe that's GP's point.


Yes but specifically with a rebase merge the commits aren’t interleaved with the commits brought in from mainline like they are with a merge commit.

EDIT: I may have read more into GPs post but on teams that I have been on that used merge commits we did this flow as well where we merged from main before a PR. Resolving conflicts in the feature branch. So that workflow isn’t unique to using rebase.

But using rebase to do this lets you later more easily rewrite history to cleanup the commits for the feature development.


So use --merges when browsing main.


You'll still get interleaved commits. If I work on a branch for a week, committing daily and merging daily from main, when I merge to main, git log will show one commit of mine, then 3 from someone else, then another of mine, etc. The real history of the main branch is that all my commits went in at the same time, after seven days, even if some of them were much older. Rebase tells the real story in this case, merge does not.


  git log --oneline --graph --first-parent


i don't think i have ever even looked at what order the commits are, i only care about the diff vs the target branch when reviewing

especially since every developer has a different idea of what a commit should be, with there being no clear right answer


That's hard to answer because I only rebase.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: