We are a team of programmers.
We have the main repo for one project.
One of programmers in our team made a pull request to that repo.
I need to fix his pull request. And I'm not a main repo owner.
How do I fetch his code?
When I go to his account - I don't see the fork of that repo (probably it's private).
Is it done like so?:
$ git remote add <name> <source> # for <source> - link to his pull request
$ git fetch <name>
$ git merge <name>/<branch>
If you want to check out a remote branch someone published, you first have to use git fetch . This command downloads the references from your remote repository to your local machine, including the reference to the remote branch. Now all you need to do is use git checkout <remote branch name> .
Simply
git fetch origin pull/<pull-request-id>/head:<local-branch-name>
git checkout <local-branch-name>
If you're on a fork not the main repo, you'll need to add the main repo as another remote (here called upstream
), then fetch from that remote:
git remote add upstream [email protected]:whoever/whatever.git
git fetch upstream pull/<pull-request-id>/head:<local-branch-name>
...
(note: in this case you obviously can't push commits to the pull request)
Add remote pointing to other programmers repo/branch:
git remote add ...
Create other's branch name:
git branch other_branch
Change a branch to other's:
git checkout other_branch
NOTE: of course you can join the command to previous one in the single line:
git checkout -b other_branch
Pull other source commits:
git pull other_source other_branch
Fix his code;
Add and commit changes:
git add
git commit
Then either push the changes into his branch, so they automatically will be added into the pull-request, then accept the request.
In case the access will be unauthorized you have to merge the changes before fixing the code, then merge the code into the main development branch, and push the changes into repo. However you shell to cancel the pull-request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With