There are some cases where you want to edit the PR which is made from a fork of your repo. Let's see how we can do this from git CLI itself.
Let's say you've a project on github and someone made a from and created a PR, but you wanted to add something before merging it with yours, but he is not replying and you really like the PR. - then you decided to edit that PR by yourself and merge. But HOW?
#. Break it down
someone named danish created a fork and worked on a branch called
feat/smthn
and created a PR.
First thing you should check is- if that PR is editable by maintainers (check very bottom right section of PR).
If it's checked, then you're good to go (it is by default).
Allowing edit from maintainers GH docs
#. Action time
First we need to create temporary remote to forked repo.
bash
This will add a remote to your fork (you can remove it later).
To verify run this command:
bash
That's done, now let's update newly added remote.
bash
This will fetch every changes made in fork to remote.
Then we need to create a branch for us to work on which is connected to remote branch which danish
worked on.
bash
This will create and checkout to branch danish-feat-smthn
which has changes made by danish
.
Make some changes...
After making some changes, do git add .
and commit it with a message.
Now- we can't directly push to branch danish-feat-smthn
, we need to push to remote branch called feat/smthn
which is in remote temp-danish-remote
.
To do so:
bash
You could alternatively use
HEAD:feat/smthn
insteadtemp-danish-remote:feat/smthn
Now check that PR- your commit will be there!
#. Potential issues
If you see something like ! [remote rejected] HEAD -> main (permission denied)
.
The other user probably disabled edit from maintainers option. Have them checked and try again.