Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Getting Started with Rails Push to GitHub

Error 403 in response to git push -u origin master

Hi, I'm getting the following message:

ā™„ git push -u origin master remote: Permission to OctoWallE/treebook_p.git denied to WallisWT. fatal: unable to access 'https://github.com/OctoWallE/treebook_p.git/': The requested URL returned error: 403

I'm running git version 2.3.2

I've tried a few times and am pretty sure it wasn't a random typo issue.

Thanks in advance for any help on this!

A 403 HTTP error means that you don't have permission to access that repository. What username do you have on GitHub?

My username on GitHub is OctoWallE

Because Git apparently thinks that your username is WallisWT. That's why it won't let you push.

Let me try to figure out a solution for you.

gitconfig is now:

[user] name = Wallis Tsai email = myname@domainname.com

WallisWT github account email is oldemail OctoWallE github account email is currentemail gitconfig email is currentemail (same as OctoWallE github account)

5 Answers

Okay, try running the following two commands in your terminal, replacing the obvious things:

git config --global user.name "Your Name Here"
git config --global user.email "Your Email Address Here"

Then close the terminal, reopen it, and try running git push -u origin master remote again.

Thanks for looking into this -- I'm getting a different error now:

ā™„ git push -u origin master remote error: src refspec remote does not match any. error: failed to push some refs to 'https://github.com/OctoWallE/treebook_p.git'

After seeing that, I went into my gitconfig file to see if something looked wrong: ā™„ subl $HOME/.gitconfig

Interestingly, even though my email & name were updated (name = OctoWallE), there was a portion that said: [github] user: WallisWT

I changed this WallisWT --> OctoWallE

I closed Terminal, reopened and tried: [15:03:10] (master) treebook ā™„ git push -u origin master remote: Permission to OctoWallE/treebook_p.git denied to WallisWT. fatal: unable to access 'https://github.com/OctoWallE/treebook_p.git/': The requested URL returned error: 403

I double-checked my $HOME/.gitconfig file, and the switch from WallisWT to OctoWallE was still there...

In your project folder, run subl .git/config from your terminal and see if WallisWT is in that file.

Thanks, subl .git/config shows

    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/OctoWallE/treebook_p.git
    fetch = +refs/heads/*:refs/remotes/origin/*

I also checked my bash profile, and the 4 references to WallisWT were all in the context of Users/WallisWT on my mac...I've included the context for these 4 references below, in case that helps:

# Aliases
function desktop {
  cd /Users/WallisWT/Desktop/$@
function code {
  cd /Users/WallisWT/Development/code/$@

*******further down in bash_profile**********

complete -o default -o nospace -F _rakecomplete rake

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[[ -s "/Users/WallisWT/.rvm/scripts/rvm" ]] && source "/Users/WallisWT/.rvm/scripts/rvm"  # This loads RVM into a shell session.if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

What are the contents of your ~/.gitconfig file?

gitconfig file is as follow. I put in a not-real email, but everything else is exactly the same. The actual email I use is the same one attached to my github account.

Thanks again for all your efforts to figure out what is going on here

    email = myemail@domainname.com
    name = Wallis Tsai
    autocrlf = input
    safecrlf = true
    excludesfile = /Users/WallisWT/.gitignore_global

    st = status
    ci = commit
    br = branch
    co = checkout
    df = diff
    lg = log -p
    who = shortlog -s --
    up = pull
    pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
  switch = !legit switch \"$@\"
  branches = !legit branches
  sprout = !legit sprout \"$@\"
  unpublish = !legit unpublish \"$@\"
  harvest = !legit harvest \"$@\"
  sync = !legit sync \"$@\"
  publish = !legit publish \"$@\"
  graft = !legit graft \"$@\"

  user = OctoWallE

  ui = true
  diff = auto
  status = auto
  branch = auto

[diff "ruby"]
  funcname = ^ *\\(\\(class\\|module\\|def\\) .*\\)

  default = current

[difftool "sourcetree"]
  cmd = opendiff \"$LOCAL\" \"$REMOTE\"
  path =

[mergetool "sourcetree"]
  cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
  trustExitCode = true

  pretty = %C(yellow)%h%Creset %s %C(red)(%an, %cr)%Creset
[filter "hawser"]
    clean = git hawser clean %f
    smudge = git hawser smudge %f
    required = true

Thank you Ryan, this still helped me in 2017!

Glad I can help! A lot of this is just me learning with you. I haven't really taken the time to learn the ins and outs of Git like I should have, and I'm learning about Git's internals right now as well.

This will be a long shot, but try running this command in your terminal:

mv ~/.gitconfig ~/.gitconfig_old

After that, restart your terminal and run this command, replacing the obvious:

 git config --global user.name "Your Real Name Here" && git config --global user.email "Your Email Address Here"

And after that, try pushing to GitHub again. It will almost certainly ask for a username and password.

Let me know if it works!

hm, it's still denying access:

ā™„ git push -u origin master remote: Permission to OctoWallE/treebook_p.git denied to WallisWT. fatal: unable to access 'https://github.com/OctoWallE/treebook_p.git/': The requested URL returned error: 403

I checked on GitHub and I do have an old / dormant account where my username was WallisWT, but I'm not sure why it's still "reading" me as that.

Can you paste the contents of your ~/.gitconfig file again? Also, is the email address you're using for your OctoWallE account the same as for your WallisWT account?

Hmm, this has me stumped. Can you try downloading GitHub for Mac and signing in there?

Davenport Kaleb
Davenport Kaleb
11,212 Points

Hey, I have the exact same problem. Have you found a solution?

Davenport Kaleb
Davenport Kaleb
11,212 Points

I figured it out! You have to change your KeyChain account on the mac settings.