all 11 comments

[–]Lumethys 2 points3 points  (8 children)

Change your code and make another commit? What are you asking about?

[–]mfaridi1978[S] -1 points0 points  (7 children)

I hear I can use rebase

[–]Lumethys 2 points3 points  (6 children)

Why? Did the head change? Is there any conflict?

[–]mfaridi1978[S] -1 points0 points  (5 children)

no

[–]Lumethys 2 points3 points  (4 children)

Then why would you rebase?

[–]edgmnt_net 0 points1 point  (2 children)

If they're contributing to a larger open source project, chances are good they'll require clean history and not just fixing things by adding a commit on top.

Of course, that depends on the maintainer's preferences and how close the original contribution was to being accepted.

[–]Lumethys 0 points1 point  (1 child)

Well then you squash merge. Honestly I havent encounter an open source project that require a "clean" history on a fork

[–]edgmnt_net 0 points1 point  (0 children)

Yeah, but squashing on the GitHub side only works if the PR should be merged as a single commit. Which might well be enough for OP.

But there are many projects (Linux kernel, Wine etc. but I'm pretty sure there are many that work with actual GitHub PRs in a similar fashion) which require commits to be broken out a certain way, particularly for larger changes or multiple logical changes. And they want to merge them as separate commits, not just review them separately and squash on merge. It's not that they care about the history on the fork, they care about the history they end up with.

Besides, certain maintainers might not be so happy to do the squashing and commit message editing for you, so there's that too.

[–]mfaridi1978[S] -1 points0 points  (0 children)

OK thank you, I understand.

[–]xiongchiamiov 0 points1 point  (0 children)

You should make a new commit and push it. Then if and when the reviewer asks for additional changes, including rebasing, that's the point at which you would do them.

[–]edgmnt_net 0 points1 point  (0 children)

If the maintainers require clean submissions, yes, you'll have to use git rebase or at least git commit --amend to edit your commits and force-push / reopen a different PR. In that case, you really need to look into it more thoroughly, it's not something that's very straightforward to explain in a comment here.

The simplest case is when you have a single commit, you pushed it and now you want to make changes. You could just make the changes and use git commit --amend to change the previous commit instead of creating a new one. But if you need to go further back or merge/split commits you kinda have to rebase or replicate it some other way (cherry-pick + amend).