k88hudson / git-flight-rules

Flight rules for git
Creative Commons Attribution Share Alike 4.0 International
41.71k stars 3.18k forks source link

git apply patch to the rescue (question) #214

Open Dagnan opened 6 years ago

Dagnan commented 6 years ago

Hi, I have a question: I've seen cases where a PR is really bad in terms of merging master multiple times, with commits before, in between etc. The kind of PR you want and should rebase, but it's really hard because of these merges. In this case you can generate a patch, and then apply it on a new branch, to get the exact copy of your old branch, but less messy.

Is there anything in this guide that talks about a similar method? Or should I add that in a new PR?

RichardLitt commented 6 years ago

I don't think we have that usecase yet. I would suggest adding it in a PR! This makes sense to me.

RichardLitt commented 5 years ago

I'd also be curious to see how to make a patch and apply it using Git, without using GitHub's concept of forking and pull requests, which are really opinionated Git maneuvers.

Dagnan commented 5 years ago

I actually had to do that this week. It's pretty basic: on your messed up branch, do git diff master..head > foo.patch, then create a new branch off master and do git apply foo.patch.

I haven't looked at how to create a pull-request for this project though.

RichardLitt commented 5 years ago

Huh, cool. If you want to add a section on this, I'd love to see it. :)

ceuk commented 3 years ago

Hey guys, just adding a +1 that I was a bit surprised that the definitive solution to contributing code seems to be "go to Github/another similar site and create a PR".

Obviously, this is by far the most common/modern method, but might be worth having something on git format-patch/am/send-email too? Those are the intended/git native tools to facilitate code sharing after all.

Edit: made a PR instead of just talking