How do I make a pull request using EGit? - eclipse

I have a local master branch and I want to create a pull request with a repo owned by somebody else. When I attempt to "push branch", I get the following text: "can't connect to any URL: https://github.com/jleclanche/fireplace: git-receive-pack not permitted"
I'm guessing that what I'm doing here is actually trying to merge, rather than making a request. How would I do this?

These are the steps necessary to fork a repository, make changes and finally open a pull request to have the changes merged back into the originating repository.
On GitHub, navigate to the repository's page and click the Fork button in the top-right corner of the page
Copy the URL of the forked repository to create a local clone in EGit
I recommend creating a new branch in the form your-name/issue-name. Working on a separate branch gives a better oversight and helps when working on multiple pull requests in parallel.
Make one or more commits that should end up in a pull request.
Push these changes to the forked repository.
On GitHub, navigate to the fork's page. You should see a message there indicating that a new branch was created and a button to create a pull request. Click this button. On the next page, you can provide more information and finally confirm the creation of the pull request.
In order to consume changes made to the originating repository, you would want to add it as a remote to your local clone.
You may even want to rename the remotes, so that the forked repository (the one you are pushing to) is named fork and for the originating repository use the default name origin.
For example:
[remote "fork"]
url = git#github.com:your-name/forked-repo.git
fetch = +refs/heads/*:refs/remotes/fork/*
[remote "origin"]
url = git#github.com:user/originating-repo.git
fetch = +refs/heads/*:refs/remotes/origin/*

In this answer, I assume that you have commit rights on the project in question, but still want to create a pull request. In this case, it's not necessary to fork the repository.
Create a local branch in Eclipse (Team -> Switch to -> New branch..., use the default values) and work on it. Eventually, push the branch to the GitHub repository.
Go to the repository on github.com.
GitHub will usually recognize that you have pushed a branch and offers the
option to create a pull request directly. Alternatively, you should be able to create a pull request from the "pull requests" tab.

If From Eclipse you commit the changes but due to conflict you cant get the Pull Request so do following steps to get pull req from git bash command
git status
git checkout develop-robot
git log [check your commit present or not]
git pull
git checkout
git rebase develop-robot
git push -u -f origin

Related

Create a pull request from a repository that is not a fork on github

forking iss not allowed (for this repository on github). So what I did was I cloned the repository to my local folder, Then made my changes and did a commit. then pushed it into my own repository on github.
Problem, my repository is not denoted as a fork in github. So there is no way to create a pull request to the original repository.
How do I set my upstream in github?
I tried to set upstream using git remote add, and create a pull request using git request-pull. But while the commands were successful, nothing showed up in github... my repository still does not show as a fork
when I try to create a pull request from the website, pushing "new pull request" button, I only see the same branch, I do not see my own fork even when choosing "across forks"
You cannot create a pull request from a repository that is not a fork. On GitHub, all the forks, plus the main repository, form a repository network, which shares objects. This is a requirement in order to create a pull request.
If you have push access to the original repository, then you can push your branch there and create a pull request from there. If you don't and the repository owner has prohibited forking, then you'll need to talk with them about how to get your change proposed.

Pull fork and submit pull request

I am working with GitHub and want to submit a pull request. When I fork the repository I don't see my changes I'm guessing because it never asked me where to link the repository to. How do I link the forked repo to a location on my personal computer for the pull request? This is for an interview and with the code done I don't know where (or how) to put it.
I'm the first to oppose noise but I don't know what other exchange site to post on. I'll close it if I'm pointed somewhere else and it doesn't get closed first.
If you have cloned the original repo locally, you can:
make sure you have a fork on GitHub (you seem to have one, where you say you don't see your changes, which is expected since you haven't push them yet)
declare that fork as your new origin
That is
cd /path/to/my/local/repo
git remote rename origin upstream
git remote add origin https://github.com/<myGitHubAccount>/<reponame.git>
Don't forget to add your changes, commit and push:
git checkout -b aNewBranch
git add .
git commit -m "Fix done in a new branch for PR (Pull Request)"
git push -u origin aNewBranch
From there, you can go to https://github.com/<myGitHubAccount>/<reponame.git>, switch to aNewBranch, and click "Make a Pull Request"

Github / EGit pull request workflow

Say I have a repo and someone forks it. Then they do work and submit a pull request. But the code contains a large number of lines and/or it creates a GUI. I'd like to fetch it so I can actually see it run from Eclipse before merging it into my master. The options I've come up with are:
Create a second repo in EGit and clone directly from their fork.
Create a new branch just for them. Then leave a comment for the request asking them to re-submit the pull request using the new branch and that I'll be closing the current request (without merging)
Always keep around a branch for them to use in their pull requests.
Besides setting up an organization on Github what else could I do?
Then leave a comment for the request asking them to re-submit the pull request using the new branch and that I'll be closing the current request
They don't have to re-submit, it you test and merge first locally, as described in the "Merging a pull request" GitHub page.
git checkout master
git pull https://github.com/otheruser/repo.git branchname
If the local merge works, then you can go ahead and merge the pull request through the GitHub web interface.
GitHub has documented how to checkout a pull request.
As I have illustrated before in "What support for git namespaces exists in git hosting services", you can use refs/pull/<PRNumber>/head as remote pull reference, in command line or in Egit when, for instance, creating a new branch.
If the PR number is 123, you can simply use the EGit Pull action, and use pulls/123/head as reference.

How to push changes from a forked project to the original project?

I’m supposed to work on my client's project on GitHub, where the changes would be on his repository. I tried to follow the fork example, but could only get the changes to go to my account repository?
In the example on GitHub, to fork a repo, they create a remote called upstream to point to the original project. I can get the changes from it by
get fetch upstream
git merge upstream/master
I was able to upload the changes into my repo by
git push –u origin
which copied my changes to my account.
I tried
git push –u upstream
To push my changes on the original account. I got the following error
You can’t push to git://github.com.octocat/SpoonKnife.git
use git#github.comoctocat/Spoon0-Knife.git
Basically, in order to collaborate with your client, you've got two main options:
Send your client a pull request (more info on this in this GitHub help item). This allows your client to review, discuss and/or request some changes to your proposal before merging it.
Request from your client to be added as a committer to their project. This would allow you to directly push your commits to their repository, without the need for a fork/cloned repository on your side.
As a side note, Spoon-Knife.git is one of GitHub's read-only repository (used for demonstration purpose) and you will not be able to commit to that (unless your client is GitHub). Thus, your client's upstream git remote should point to a different repository
Here are the steps (to be followed after you forked and cloned the repository to your local disk):
Remove the upstream reference: git remote rm upstream
Add in your client's info - git remote add upstream git#xxxxxx
Push your changes - git push -u upstream master . git push -u will set the HEAD of the remote repository.
Same if you want to pull - git pull upstream master
If you prefer the name origin replace upstream with origin, but still follow step 1 to remove the reference to Spoon-Knife.git. Then in step 2 - git remote add origin git#xxxx.
git://github.com.octocat/SpoonKnife.git is a read-only URL. As GitHub suggests, the corresponding write-able URL is git#github.comoctocat/Spoon0-Knife.git.
If you want to be able to push on the upstream repository, you will have to ask (to the upstream team, i.e., your customer) to be added as a committer.

after I fork a github project, how can I stay current with the original project?

On github, after I fork a project, modify it, then submit my pull request, it seems that I have to delete and re-fork in order to stay current with any changes made after my pull request is honored.
It seems tedious to have to keep deleting the repo to keep it current. Is there some way to keep it current without deleting and re-forking?
You should add the original project as a remote to your working copy. Then you can pull changes from the original repository and push them to your forked repository. The commands for this look something like:
git remote add upstream <original repo url>
git pull upstream master
git push origin
What you can do is create a pull request in your forked repo by comparing to the original repository and then merge it in your repository.