Can I modify someone else's pull request and push it back in its branch? - github

GitHub explains you can fork, modify, commit, push and trigger a pull request. They also explain that you can still modify, commit, push and the request is updated on the website.
I would like to know if it is possible to do the exact same thing but not being the author of the fork? I am the owner of a repo with pull requests I would like to correct myself but still discuss afterwards... I was trying to push my changes into the author's repo (thinking some right access would be calculated) but the access is denied.

When creating a pull request (PR) on GitHub, you can select the option that maintainers are allowed to commit changes to your PR. You can also do this after the PR is already created: In the detail view of the PR, on the lower right, under "Unsubscribe", "participants". So if you want to commit to a PR of someone else on a GitHub repository you own: Ask them to give you this permission.
From the GitHub help pages: "Only pull request creators can give upstream repository maintainers, or those with push access to the upstream repository, permission to make commits to their pull request's compare branch." (Allowing changes to a pull request branch created from a fork)
Unfortunately, as far as I know, in order for someone to commit to the PR, you would have to give them write access to the repository and can't just selectively give them write access to the PR.

Official GitHub support answer at this date
It would be up to the owner of the forked repository to decide if they
want to pull your changes into their fork.
You would modify their Pull Request and merge it into your repository.
You could then request them to pull down the changes you have made
into his fork which would synch his fork with yours.

Related

Change the target branch of an existing pull request to another fork

I forked a repository A.. say B
I created a pull request from branch B.branch1 TO B.master
The pull request got some review comments.. I resolve them and so on..
I now want to change the base from B.master to A.master(parent repo)
How can I do this in case of an existing PR?
Since I am not seeing the option to change the base branch to another repo..
I know I can create a new pull request but that would lose all the review conversation.
A pull request is an entity that is tied to the repository it was created in. Other repositories (even if forked from the original repository) may have other rules regarding pull requests, code reviews or repository access in general. The developers giving you a code review in fork A might even not be able to do so in fork B.
Therefore you can not move your pull request to another repository.
I suggest you close your current pull request and open a new one. You can link to the old PR and explain the situation so people can still see the code review conversation that was going on in the original PR.

Validate commit message contains Jira Ticket Number when squash merge from GitHub webUI

When doing a squash merge, following a successful Pull Request, on github I would like to validate that the squash merge commit message contains a Jira ticket number. If it does not the squash merge should fail until a proper commit message is entred by the user.
Right now this needs to be done manually and sometimes I forget to include the ticket number I would like an automatic way to make sure I don't forget to do it.
I know that I can use hooks locally to force a Jira Ticket number but I dont care about how the user work on his on branch. I really just want the protected branch commits to all start with a Jira ticket
I do not have github entreprise so I can't use a pre-receive hook.
I have look into github action but not sure this is the proper way to go.
Some Reference but no solutions:
Ensure github PR squash merge commit comments contain issue ID
https://github.com/github/feedback/discussions/8688

Why does GitHub API commit object point to a pull request that does not contain the commit?

I created a script that, from a commit in a repository, tries to figure if it belongs to a pull request and, in that case, will return all commits in that pull request. Debugging the output, I found that some commit objects refer to a pull request, but the pull request object does not contain such commits.
Let me do a practical example:
In the GitHub Repo
https://github.com/DemocracyClub/yournextrepresentative
there is the commit
0722309a9c242aac28d2cb33798abbd18b233aa0
that belongs to the pull request
https://github.com/DemocracyClub/yournextrepresentative/pull/55
So, in the GitHub website seems to be all good. No reverts, no amends, no weird git functions that would create a mess in the git history.
So, GitHub API correctly identifies the pull request with the URL
https://api.github.com/repos/DemocracyClub/yournextrepresentative/commits/0722309a9c242aac28d2cb33798abbd18b233aa0/pulls
and gives me as link of PR's commits the following one:
https://api.github.com/repos/DemocracyClub/yournextrepresentative/pulls/55/commits
BUT if you look in that link, there is no reference to the commit
0722309a9c242aac28d2cb33798abbd18b233aa0
Any idea of why is this happening?

On Github, how do I find what pull requests individual file commits belong to

On GitHub, I can see the history of commits of a file under .../commits/master/filename. What I want to know is, assuming these changes were merged into master via Pull Requests, what Pull Request did the change come from? Is there an easy way to do that?
Since Oct. 13, 2014, this should be easier:
Linking merged pull requests from commits
We've been including the containing branches and tags on commit pages to give you more context around changes. Now, commits in a repository's default branch will also show you the pull request that introduced them.
In the pull request, you can see the discussion around why the commit was introduced, and get a clearer picture of the reason for the change.
As always, if you know the commit SHA, you can skip the commit page and search for the pull request directly.
For instance:
You can see for the file hakimel/reveal.js/plugin/markdown/markdown.js, my contribution now comes with a reference to the PR #734 it originated.
Note however that:
neither GitHub Get single commit API, like https://api.github.com/repos/hakimel/reveal.js/commits/f2097417daca80b2caaed2661ee646e861d789c8
nor GitHub Get a commit API, like https://api.github.com/repos/hakimel/reveal.js/git/commits/f2097417daca80b2caaed2661ee646e861d789c8
will include the reference to the PR...

Github pull request

I am still new to github and now I am confused. I forked a repo a while ago. Then locally on my computer pulled the changes from the original repo and merged them into mine. Then I did my change and committed it. Then I pushed everything to my forked repo.
Now I want to send a pull request. But I just want to send my one commit and not everything else (which is already in the original repo). But I can't find a way to do so.
Thanks for your help.
Go to to your forked repo, and then click on Compare and Review
Select the target branch to merge
Click to create a pull request for this comparison
Enter a title and description for your pull request
Click Send pull request
https://help.github.com/articles/creating-a-pull-request