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

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

我正在尝试使用 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

这是因为您的遥控器是使用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

在 SourceTree 中:Tools-Options-Authentication 然后 select "Set as default" 为正确的帐户和推送对我有用。