Reputation: 205
Recently I have created new github repository and finished all my work on the master branch and pushed. I should have created a branch instead of working on a master, now this code needs to be reviewed so reviewers may not be able to add comments on master branch so is there any away of allowing reviewers to comment? thanks
Upvotes: 4
Views: 2668
Reputation: 1888
I think the most efficient approach here is a "low tech" one:
At the end of the day the review is just people working together on improving the code and comments. Besides, it is pretty typical for someone to do an initial "big bang" for version 0.1, and then start the official PR-controlled process.
That being said, Git is flexible when it comes to history manipulation. Right now you have something like this:
A > B > C > D <--- [master]
It is relatively easy to convert it to:
A > <--- [master]
B > C > D <--- [featureA]
Just create new branch, move master branch pointer back in history and force push to the repo. This process was explained in details, for example, here:
Move the most recent commit(s) to a new branch with Git
Git branch is just a pointer, so change like that will not affect a single commit, just put [master]
and [featureA]
pointers to different locations.
After that you can create PR and have all the discussions you want. And move [master]
to the tip once it is accepted.
However, such operations can easily destroy things in your entire repository and/or confuse other users if they have already started work on the existing master. I would personally not do something like this just to have a chat with team about the recent changes! If you go for anything like that, make sure you have properly backed up your entire repo somewhere.
Upvotes: 3
Reputation: 18764
New Repo so should be simple under the assumption that you are ok with deleting and re-creating master.
Create new branch off of master
, say feature-1
using these steps.
git checkout master
git checkout -b featureA
git push -u origin feature A
Delete master branch from remote and local. To do this, first go to settings in your repo and change the default branch to be featureA
.
Now lets delete the master branch locally and on remote.
git push -d origin master
git branch -D master
Now lets re-create an empty master branch, delete all staged files and recreate a readme.md (or something similar as you need atleast a commit to push it to remote).
git checkout --orphan master
git rm -rf *
touch README.MD
git add README.MD
git commit -m "initial commit"
git push -u origin master
Then change the default branch back to master and create your PR from feature branch that you created.
You will need to have folks pull again so that their local copies are synced with github.
Upvotes: 6