使用Sourcetree,我试图将我的文件推送到github

时间:2015-07-02 16:57:14

标签: git github atlassian-sourcetree

我正在尝试使用Sourcetree将我的文件推送到github,但是我收到以下错误:

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

回复编辑(谢谢TheGeorgeous)

我实施了

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

git push source <branch_name>

然后我收到了一条消息;

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

然后,我尝试使用Sourcetree推送。

但是我收到了错误消息;

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

2 个答案:

答案 0 :(得分:2)

这是因为你的遥控器是使用ssh配置的,你可能没有配置你的ssh。

首先打开Source Tree终端

然后像这样删除您的遥控器:

git remote rm origin

然后添加此遥控器:

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

他们试图再次推动。

修改

根据您在评论中所说的内容,您可能必须这样做

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

编辑2

该错误是因为正确的远程是source,但SourceTree尝试推送到您没有写权限的origin

使用

检查遥控器
git remote -v

并删除所有遥控器,然后将正确的遥控器添加为origin

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

答案 1 :(得分:0)

在SourceTree中:Tools-Options-Authentication,然后为正确的帐户选择“设置为默认值”,并为我完成推送。