Search code examples
gitgithubatlassian-sourcetree

Using Sourcetree, I am trying to push my file to github


I am trying to push my file to github using Sourcetree, however I get the following error:

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/challenge2/Soma:refs/heads/challenge2/Soma 
Pushing to git@github.com:camenergydatalab/EnergyDataSimulationChallenge.git
ERROR: Permission to camenergydatalab/EnergyDataSimulationChallenge.git denied to soma11soma.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.
Completed with errors, see above

REPLY TO EDIT (Thank you TheGeorgeous)

I implemented

git remote add source http://github.com/soma11soma/EnergyDataSimulationChallenge.git

and

git push source <branch_name>

then I got a message;

Soma-Suzuki:~ Suzuki$ git remote add source http://github.com/soma11soma/EnergyDataSimulationChallenge.git
Soma-Suzuki:~ Suzuki$ git push source challenge2/Soma
Username for 'https://github.com': soma11soma
Password for 'https://soma11soma@github.com': 
Counting objects: 5322, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1569/1569), done.
Writing objects: 100% (5322/5322), 6.13 MiB | 237.00 KiB/s, done.
Total 5322 (delta 2449), reused 5317 (delta 2447)
To http://github.com/soma11soma/EnergyDataSimulationChallenge.git
 * [new branch]      challenge2/Soma -> challenge2/Soma

And next, I tried to push, using Sourcetree.

But I got the error message;

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/challenge2/Soma:refs/heads/challenge2/Soma 
Pushing to http://github.com/camenergydatalab/EnergyDataSimulationChallenge.git
remote: Permission to camenergydatalab/EnergyDataSimulationChallenge.git denied to soma11soma.
fatal: unable to access 'https://github.com/camenergydatalab/EnergyDataSimulationChallenge.git/': The requested URL returned error: 403
Completed with errors, see above

Solution

  • It is because your remote is configured using ssh and you may not have configured your ssh.

    First open the Source Tree terminal

    Then remove your remote like this:

    git remote rm origin
    

    Then add this remote:

    git remote add origin http://github.com/camenergydatalab/EnergyDataSimulationChallenge.git
    

    They try to push again.

    EDIT

    Based on what you have told in comments, you may have to do this

    git remote add source http://github.com/soma11soma/EnergyDataSimulationChallenge.git
    git push source <branch_name>
    

    EDIT 2

    That error is because the correct remote is source but SourceTree tries to push to origin to which you have no write permissions.

    Check you remotes using

    git remote -v
    

    and remove all remotes then add the correct remote as origin

    git remote add origin http://github.com/soma11soma/EnergyDataSimulationChallenge.git