Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW01 - issue with pushing #17

Open
sbridgewaters opened this issue Mar 29, 2018 · 4 comments
Open

HW01 - issue with pushing #17

sbridgewaters opened this issue Mar 29, 2018 · 4 comments

Comments

@sbridgewaters
Copy link
Collaborator

I am receiving this error when I try to push my changes. I have saved and staged the readme file and committed all of my changes.

git push origin refs/heads/master
remote: Permission to uc-cfss/hw01.git denied to sbridgewaters.
fatal: unable to access 'https://github.com/uc-cfss/hw01.git/': The requested URL returned error: 403

@sbridgewaters
Copy link
Collaborator Author

Also, I have been able to push to GitHub, so I do not think this is a credentials issue.

@bensoltoff
Copy link
Contributor

Make sure whenever you clone a homework repository, use the url for the forked version, not the master repository. So for the first homework, I would use https://github.com/bensoltoff/hw01 when I clone the repo, not https://github.com/uc-cfss/hw01. If you use the master repo url, you will get an error when you try to push your changes to GitHub.

For an example, let's say I wanted to make a contribution to ggplot2. I should fork the repo and clone the fork. Instead I goofed and cloned the original repo. When I try to push my change, I get an error message:

remote: Permission to hadley/ggplot2.git denied to bensoltoff.
fatal: unable to access 'https://github.com/hadley/ggplot2.git/': The requested URL returned error: 403

I don't have permission to edit the master repo on Hadley Wickham's account.

How do I fix this? I could go back and clone the correct fork, but if I've already made several commits then I'll lose all my work. Instead, I can change the upstream url: this changes the location Git tries to push my changes. To do this:

  1. Open up the shell

  2. Change the current working directory to your local project (should use the cd command)

    Note that if you do this using the shell that is built into RStudio, then you should already be in your local project.

  3. List your existing remotes in order to get the name of the remote you want to change.

    git remote -v
    origin	https://github.com/hadley/ggplot2.git (fetch)
    origin	https://github.com/hadley/ggplot2.git (push)
  4. Change your remote's URL to the fork with the git remote set-url command.

    git remote set-url origin
  5. Verify that the remote URL has changed.

    git remote -v
    origin	https://github.com/bensoltoff/ggplot2 (fetch)
    origin	https://github.com/bensoltoff/ggplot2 (push)

Now I can push successfully to my fork, then submit a pull request.

@sbridgewaters
Copy link
Collaborator Author

Thank you so much!!! That makes a lot of sense.
Sorry for making such a big mistake right off the bat!

@bensoltoff
Copy link
Contributor

@sbridgewaters Not a problem. It's a very common mistake, especially if you've never used Git before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants