Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for Pull Requests on GitHub

I've read this and this discussions but still have troubles with understanding the best way of collaborating on GitHub.

Suppose I've forked a repo and develop it independently (the original repo has not been active for a while). So I do have my own develop branch, where I do all changes: branching from feature it, developing there and then merging back to develop. From time to time I want to submit a PR to original repo. But I can't do PR from feature, as it will include all history of develop. So that's what I do:

  • checkout master that track original repo
  • brahnch from it
  • cherry-pick from feature and push it to GitHub
  • submit a PR

When those PR's are merged to master of original repo, I pull from it and then merge master to develop.

It works rather fine, but it results in multiplying identical commits in my own repo, so I'm not sure if cherry-picking is the best way here?

Branching from master would be perhaps better, but often there's a situation when I've done feature-2 that depend on feature-1; and feature-1 is still waiting as PR to be merged, but not in master yet.

I would appreciate any suggestions and examples.

like image 449
Vladimir Avatar asked Mar 05 '15 14:03

Vladimir


People also ask

What should I write in a pull request GitHub?

Be explicit about what feedback you want, if any: a quick pair of :eyes: on the code, discussion on the technical approach, critique on design, a review of copy. Be explicit about when you want feedback, if the Pull Request is work in progress, say so.

How often should you do pull requests?

To me, two times a day is a good interval for when to review. I like to check for pull requests in the morning and after lunch. At those times you naturally have a break from all the context you've built up in your mind.

How many commits Should a pull request have?

Have one commit per logical change and one major feature per pull request. When you submit a pull request, all the commits associated with that pull request should be related to the same major feature.

What is a good size for a pull request?

How can we determine the perfect pull request size? A study of a Cisco Systems programming team revealed that a review of 200-400 LOC over 60 to 90 minutes should yield 70-90% defect discovery. With this number in mind, a good pull request should not have more than 250 lines of code changed.


1 Answers

In theory it always depends on the project you are working on, and the head of the project.

Generally speaking you only commit to master when it is a release build, or something that can at least compile without errors. But some project just throw everything into master.

Truly, in my own projects, and opinion, your pull requests should be placed into the main projects develop branch, then when the time comes, everything from develop gets merged into master.

Your workflow would basically stay the same. Branch from develop to create a new feature-X, commit to feature-X, and then you would submit a pull request on feature-X. Once merged into develop you would pull that down, and continue working; or just merge it on your personal fork and continue working, git should understand. Once the project lead feels the project is in it's next version, he/she would merge develop into master.

Check out this 5 minute read: Understanding the GitHub Flow.

like image 153
Ryen Nelsen Avatar answered Sep 17 '22 16:09

Ryen Nelsen