12

I have read postings and performed code reviews on pull requests, for example: "How to create and review a GitHub pull request"

GitHub Question: You (as a solo contributor) have been working on a body of code you have been committing to GitHub for a while. Then later within GitHub, you wish others to code review the commit master branch and wish for them to add add their suggestions.

Basically on GitHub, inviting others on GitHub to perform on full code review on the committed code in the master branch, and allowing their change suggestions to be added. The same code reviewing experience if requesting a code review on a pull request.

Is this possible in GitHub?

Thank you

Jeff
  • 1,917
  • 1
  • 25
  • 43
  • 2
    I don't think this is a built-in feature of Github, but this post (http://astrofrog.github.io/blog/2013/04/10/how-to-conduct-a-full-code-review-on-github/) gives a good example of how to use Git magic to create a pull request against an entire repository. – Adil B Nov 01 '18 at 15:21
  • 2
    @AdilB Thank you for suggesting ["How to conduct a full code review on GitHub"](http://astrofrog.github.io/blog/2013/04/10/how-to-conduct-a-full-code-review-on-github/). I am checking it out now! – Jeff Nov 01 '18 at 15:27
  • @AdilB Your comment answers the question and it would be great to have the linked blog post summarised here as an answer. Maybe we can make it a Community Wiki? – Faheel Jan 27 '21 at 09:29

1 Answers1

4

The steps from the post worked perfectly for me.

Here is a summary of the steps to follow, including a correction on one of the git commands.

Starting from the master branch with all changes committed.

git checkout --orphan full_review
git rm -r --cached *
git clean -fxd
git commit --allow-empty -m "Empty commit"
git branch empty
git merge master --allow-unrelated-histories
git push origin full_review
git push origin empty

After these steps, your repo contains an empty branch and a full_review branch, which you can use to create a pull request:

Pull request

Lolo
  • 3,935
  • 5
  • 40
  • 50
  • 1
    Please notice the command for merge master might need to change to merge main – Ron Oct 18 '22 at 12:51
  • @Ron do you know, when it is time to merge with master, how to change the `Merge pull request` button to merge to the `main` / `master` branch ? I am somewhat new to working withe Github interface for PRs. Note: my changes were performed on the full_review branch, which I think isn't the correct branch to do this on. – steveb May 12 '23 at 21:33
  • @Lolo If you have some time and know how to do it, perhaps you could add steps for the following: 1. which branch to make edits on for review 2. After the PR is accepted, how to merge to `main` (or `master`) instead of the `empty` branch. Thanks for this answer either way, it has been very helpful! – steveb May 12 '23 at 21:39
  • After doing some looking, it turns out merging to `main` is pretty easy. One can modify the PR to merge with `main` instead of `empty`, after the code review is done. If there is a better practice, feel free to comment. – steveb May 13 '23 at 01:48