How to request a code review on a committed master branch within GitHub?
Asked Answered
H

1

14

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

Hal answered 1/11, 2018 at 14:52 Comment(3)
I don't think this is a built-in feature of Github, but this post (astrofrog.github.io/blog/2013/04/10/…) gives a good example of how to use Git magic to create a pull request against an entire repository.Sussna
@AdilB Thank you for suggesting "How to conduct a full code review on GitHub". I am checking it out now!Hal
@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?Nummulite
B
9

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

Blockus answered 28/4, 2022 at 13:53 Comment(4)
Please notice the command for merge master might need to change to merge mainJarita
@Jarita 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.Telega
@Blockus 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!Telega
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.Telega

© 2022 - 2024 — McMap. All rights reserved.