Pull fork and submit pull request - github

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"

Related

how to make fork on github updated

I found good project (boilerplate), which I am going to use as starting point for my project.
And I forked it.
git clone https://github.com/fork.git forkdirectory # clone my fork to my local PC
git branch mybranch # create new branch for my specialities, which will be different from boilerplate
git checkout steklo # change the branch, which I will work on by default
Then I make some changes and check that they appear in my fork
git add . # add all changes for commit
git commit -m"commit comments" # make commit
git push -u origin mybranch # push changes to mybranch
I tested that for next changes I can just do shorter
git push
But what should I do when I will see that initial boilerplate updated?
1) How to apply all updates to my fork?
2) And then how to apply all updates from my fork to my local clone?
I think i understand your confusion about it,
This process steps are
Fork the repository.
Update the repository.
Create a pull request
Now Owner of the repository sees, if your request is valid, he merge the request.
You've already completed first two steps, now you only need to submit a pull request.
Goto Pull requests of your forked repo
Create a new pull request
Owner will see if it is valid then he will merge your pull request to the repo
that's all
Cheers :)

Pushing to someone else's branch on Github

I'm fairly new to GitHub, so I hope you can help out. There's a branch on a repo that I want to push changes to, but I'm not added as a collaborator on it. What steps do I need to take to push changes to that branch?
I have done some research and found that I may need to fork the repo, make changes locally then create a pull request, but I'm still a bit confused about it. I would appreciate any help.
You can't simply push to the branch which you dont have the write access. You can simply fork the repo by clicking it fork button. Then clone the repo locally by using the command below
git clone https://github.com/your-username/project.git
Then you need to checkout to the branch which you need to make the change just use:
git checkout branch_name
Then make the necessary changes. Now you will have to commit the changes:
git add --all .
git commit -m "changes description"
git push
Now visit the repository in your profile. You can see a notification to open a new pull request.
Please see this for more info: https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/

How do I make a pull request using EGit?

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

How to submit a pull request from a cloned repo?

How to submit a pull request from an existing locally-cloned repo?
Often, I want to look at some libraries source code from github, so I clone it. Later, I discover some issue with the code and raise it on a mailing list, often in passing. The library author says "nice find, can you send a pull request?".
And the answer is "not that easily". I haven't forked the repo yet, Ive cloned it. And there doesn't seem a way I can find to submit a pull request from a cloned repo?
If this limit is true, it feels like the sensible reaction is to fork anything and everything you ever look at, just so that if you ever might want to contribute, you can. And that fills up your github account with many inactive forks.
Doesn't seem a lot of talk about this issue - am I the only person whom this problem affects?
Fork the repo on GitHub, then add your fork repo as a remote to your local cloned copy:
git remote add myfork https://github.com/<myGitHubAccountName>/<repoName>.git
Then you can push to your fork:
git push myfork master
If you're doing more than just this one pull request, you can remove the origin remote and name your fork as origin:
git remote rm origin
git remote add origin https://github.com/<myGitHubAccountName>/<repoName>.git
This is typically what I do. Sometimes I add the original origin as upstream so I still have a reference to it.
If you're ok with installing another binary in your path, github has released a nice little tool called hub.
If you've cloned someone else's repo:
$ hub fork # This creates a fork and adds your repo as a remote
$ git push YOUR_USER feature # push the changes to your new remote
$ hub pull-request # will open your browser
I always clone instead of fork as well and the following steps work for me:
Create a new branch on your cloned repo and make the new change.
Push the change to your branch as the following:
git push origin insert_your_working_branch_name
Now you should be able to find your working branch in pull request from github master.

Is there a quick way to shift to a fork in github?

The following happens to me from time to time:
clone something from github
discover something I want to fix.
want to offer it back.
Go make a fork
clone my fork
manually merge my changes to the fork
open a pull request
Somehow, it seems to me that there should be a simpler way to get from 'I've got local changes in a local branch' to 'I've got changes in a fork I can submit a pull for.'
Is there?
Github has the hub gem for maniplating their API.
Secondarily ( and I think what you're looking for) you can add a second remote to your original repo like
git remote add myfork git://github.com/defunkt/hub.git # for the case of hub
and then
git push -u myfork branchname
to push branchname up to your fork from the original repo. The -u flag sets that branches upstream to be your fork.