kandi X-RAY | gh-review Summary
kandi X-RAY | gh-review Summary
gh-review
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gh-review
gh-review Key Features
gh-review Examples and Code Snippets
Community Discussions
Trending Discussions on gh-review
QUESTION
I follow the generic OSS structure:
- the OSS' remote repository hosted on GitHub
- a fork of the OSS remote repository to my own remote repository
- a clone of the fork on my remote repository to create a local repository
Thus, a contributor would create a new branch locally, push the changes to his/her remote repository, and then open a pull request to the OSS' remote repository.
This has been working well. However, the main issue comes when I try to review another contributor's pull request by fiddling with it locally.
So I have fetched a pull request made to the OSS' remote repository using this command:
git fetch upstream pull//head:
followed by git checkout
and it was successful. I played around with the PR, and reviewed it on GitHub. Then, the contributor updated the PR by pushing new commits to their branch (on their remote repo), which was automatically reflected in the PR.
Now, I want to be able to get the updates locally so that I can try the changes again. I understand that my copy of the PR branch does not track the remote branch by default, so I tried to set it to track the PR:
git branch --set-upstream upstream/pull//head:
like how I have done when I first fetched the branch. However, I got the response that
error: the requested upstream branch 'pull//head:' does not exist
I tried again with:
git branch --set-upstream-to upstream/pull//head:
which also failed with the same error.
Then, I thought, is it because a PR is like a 'reflection' of the branch on someone's remote repository, so if I want to track an upstream branch I should track from the person's remote repository?
So I added the contributors' remote repository as a remote, and tried again:
git branch --set-upstream-to
and I still faced the same error.
I did some Googling, and I found this, but I do not want to get all the pull requests. I also found links like this one but nope, not the help that I need there.
Can anyone point out what is wrong with the way that I am doing things now? Thanks!
Edit: Is there an easier way to do things aside from what has been proposed by Marina Liu - MSFT below?
...ANSWER
Answered 2018-Apr-11 at 06:38The problem—or at least the first one—here is that you cannot use an upstream to refer to a GitHub pull request reference.
In Git, an upstream on a branch consists of two parts:
- The name of a remote, such as
origin
- The name of a branch on that remote, such as
master
Git puts these two together to get refs/heads/master
—this is the name on the remote—then runs this string through the fetch
setting(s) for the remote. The standard fetch
setting for the remote named origin
is +refs/heads/*:refs/remotes/origin/*
, so if the upstream is currently set to the pair <origin
, master
>, the name that Git looks up in your own repository is refs/remotes/origin/master
, which is your remote-tracking name for their master
.
Note the assumption in here that the name on the remote begins with refs/heads/
.
The actual name of a pull reference on GitHub begins with refs/pull/
, not refs/heads/
, so that the full name of the commit you want for pull request #123 is refs/pull/123/head
. There is no way to spell this that starts with refs/heads/
because this is not a branch name.
Now, you can—as suggested in your first link—add an extra fetch
setting:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gh-review
To build a distribution run the following commands corresponding to your operating system:.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page