Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add another reason to avoid rebasing #60

Merged
merged 5 commits into from
Nov 14, 2023
Merged

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Nov 1, 2023

It's important to note that rebasing can be as confusing to GitHub as it is to reviewers.

It's important to note that rebasing can be as confusing to GitHub as it
is to reviewers.
@mcmire mcmire requested a review from a team as a code owner November 1, 2023 23:06
@HowardBraham
Copy link

I may be in the minority on this, but I find it much easier both when I rebase and when others rebase. This could be because I use the Git GUI called SmartGit. I can understand that rebasing may be harder for command-line people (which is probably the majority). But I do believe that command-line people are not usually "seeing what's really going on."

@MajorLift
Copy link
Contributor

MajorLift commented Nov 2, 2023

@HowardBraham The focus of this article is on how rebasing affects review flow, not commit history.

docs/pull-requests.md Outdated Show resolved Hide resolved
@mcmire
Copy link
Contributor Author

mcmire commented Nov 2, 2023

@HowardBraham:

I may be in the minority on this, but I find it much easier both when I rebase and when others rebase. This could be because I use the Git GUI called SmartGit. I can understand that rebasing may be harder for command-line people (which is probably the majority). But I do believe that command-line people are not usually "seeing what's really going on."

When you rebase, what do you usually do? Are you trying to trim the number of commits so the history is easier to work with?

Do you usually rebase as you go along or at the end before you merge?

How do you find it easier when other people rebase? As @MajorLift alluded to, there are some undesirable effects it creates on pull requests which I've detailed here, but I'm curious if you've ever run into them?

@Gudahtt
Copy link
Member

Gudahtt commented Nov 6, 2023

When I use rebase locally, typically I'm just cleaning up the commit history for my own benefit. I try to only do this when the PR is in draft as well, so that it doesn't impact reviewers. For some PRs it can be helpful to have commits that can be reviewed independently, which rebasing can help accomplish.

I also prefer to use rebase when updating a PR on GitHub, because again it makes the commit history easier to read and navigate

@mcmire
Copy link
Contributor Author

mcmire commented Nov 13, 2023

When I use rebase locally, typically I'm just cleaning up the commit history for my own benefit. I try to only do this when the PR is in draft as well, so that it doesn't impact reviewers.

Sure, that makes sense. Do you rebase once people start leaving comments, though?

On the other side, when you are a reviewer on a PR, do you notice any effects from rebasing?

@Gudahtt
Copy link
Member

Gudahtt commented Nov 13, 2023

Typically no, I don't rebase after people start leaving comments. I try to avoid it as soon as the PR is out of draft.

As reviewer, yes I have been confused sometimes in the past when a PR has been rebased. Though the examples I can think of are cases where the author squashed new commits into old ones. I can't think of any cases where the "Update with rebase" button has caused confusion, I tend to prefer that because it makes it easier to review the commits on that PR.

@mcmire
Copy link
Contributor Author

mcmire commented Nov 13, 2023

I can't think of any cases where the "Update with rebase" button has caused confusion, I tend to prefer that because it makes it easier to review the commits on that PR.

Okay. I've removed that paragraph here: 73409f0

@mcmire
Copy link
Contributor Author

mcmire commented Nov 13, 2023

Also in response to both @HowardBraham and @Gudahtt, I've added a clause clarifying when to avoid rebasing: specifically, once people start leaving comments. This allows you as the author to rebase freely while in draft mode. Does that help or should I qualify this further?

@HowardBraham
Copy link

Sorry I didn't answer this question earlier. Yeah this change helps. I agree that rebasing can make the commit history easier to read and navigate when I'm a reviewer. The major disadvantage for me is occasionally you get a Git error and it's confusing.

Another reason I would use rebase, force-push, and squash is if I'm pushing not to get feedback from reviewers, but just to make CI test my changes.

@legobeat
Copy link

legobeat commented Nov 14, 2023

Agreed and for me this is the major concern which I think of roughly as "once people depend on my work, rebasing and force-pushing must be done with consideration". Someone having forked from my branch (of which I may not be aware) would be even stronger consideration than a review in that sense.

There's also a clear distinction in my mind between what I consider non-destructive rebases (what you'd get when clicking "rebase" to sync in the GH UI; cleaning up history, squashing, amending commit messages; when git diff $PRE_REBASE $POST_REBASE is empty) vs actually changing stuff.

Consider a long-running open PR. At some point, upstream (main) has changes merged which would cause a big merge conflict, requiring non-obvious changes to resolve. What do? If the PR has already had notable time and attention to review, I would say merging-and-resolving is preferred since the reviewers would then by default consider just changes since their last review. On the other hand, if no one else has properly looked at it yet, the first implementation is now irrelevant and keeping that and a merge commit around in history is just noise and unnecessary cognitive overhead for everyone. Whether in draft or not would be another factor.

I would at the same time say "avoid merge commits whenever possible". There's certainly a tension there and while I don't think simple rules can capture all relevant situations for those judgment calls perfectly, it's certainly an important aspect of the development process worth spending attention on.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Probably still room to refine this further but it definitely seems like a step forward

Copy link
Contributor

@MajorLift MajorLift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well!

@mcmire mcmire merged commit 56b7463 into main Nov 14, 2023
4 checks passed
@mcmire mcmire deleted the tweak-pull-request-guide branch November 14, 2023 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants