Riwaz Poudyal
Riwaz Poudyal

Reputation: 897

Creating a pull request to a repository I can push to

Another git pull request question, but I looked at a lot of them and none answered my question.

I had a branch, say A, of a github repo I am a contributor for and have push rights to, on my machine. I forked and created a pull request for A in the repo and then added and committed more changes to this branch locally.

Now I want to create another pull request for these changes; however, the commits are only saved locally. I want to push to a remote, but

git remote -v

returns

origin   https://github.com/some_user/repo_a (fetch)
origin   https://github.com/some_user/repo_a (push)
upstream https://github.com/some_user/repo_a (fetch)
upstream https://github.com/some_user/repo_a (push)

All the links are to the main repo. I looked at my list of repositories and there is no copy of the repo there. So, I cannot change the origin or the upstream to something else.

As I said, I want to push the new changes and create a pull request, but I can't get it done.

Upvotes: 2

Views: 56

Answers (2)

Riwaz Poudyal
Riwaz Poudyal

Reputation: 897

The problem was I didn't have a remote fork to start with. I went to the REPO and clicked on 'fork this repo' on the top right. This created a copy of the repo on my account, which gave me a link to push to.

After changing the upstream to this link, I could push to this repo, and create a pull request from it.

Upvotes: 0

bitoiu
bitoiu

Reputation: 7484

In a nutshell, you need to define the correct remote for your fork and push to it.

  1. Visit your fork on www.github.com
  2. Grab the remote SSH or HTTPS remote url from your fork:enter image description here
  3. On the command line add the new remote

    git remote add myfork REMOTE_URL

  4. Confirm that the new remote was added properly by running the command you've mentioned above. You should see the new myfork remote listed.

    git remote -v

  5. Push your commits to this new remote to whatever branch you want:

    git push myfork [BRANCH_NAME]

GitHub has a good tutorial on the matter as well: https://help.github.com/articles/fork-a-repo/#step-3-configure-git-to-sync-your-fork-with-the-original-spoon-knife-repository

Upvotes: 1

Related Questions