2017-03-02 74 views
0

閱讀我有以下我.git/config權限被拒絕(公鑰)。致命的:無法從遠程倉庫

1 [core] 
    2  repositoryformatversion = 0 
    3  filemode = true 
    4  bare = false 
    5  logallrefupdates = true 
    6 [remote "origin"] 
    7  url = [email protected]:monajalal/instagram-scraper.git 
    8  fetch = +refs/heads/*:refs/remotes/origin/* 

當我試圖把更改主我得到這個錯誤:

$ git push -u origin master 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

我曾嘗試這兩個但仍然得到錯誤:

2150 git remote set-url origin https://github.com/monajalal/instagram-scraper.git 
2154 git remote set-url origin [email protected]:monajalal/instagram-scraper.git 


[email protected]:~/computer_vision/instagram/instagram$ git log 
commit e69644389a5c7be65ae6eae14d74065e221600cb 
Author: Mona Jalal <[email protected]> 
Date: Wed Mar 1 17:48:00 2017 -0600 

    scrapy for instagram skeleton 
[email protected]:~/computer_vision/instagram/instagram$ git status 
On branch master 
nothing to commit, working directory clean 


$ uname -a ; lsb_release -a 
Linux pascal 3.13.0-62-generiC#102-Ubuntu SMP Tue Aug 11 14:29:36 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 
No LSB modules are available. 
Distributor ID: Ubuntu 
Description: Ubuntu 14.04.5 LTS 
Release: 14.04 
Codename: trusty 

請建議修復。

+3

**「權限被拒絕(公鑰)」 **,你有沒有在你的GitHub帳戶中添加你的公鑰('〜/ .ssh/id_rsa.pub')? –

回答

0

可能不是最好的解決方案,但考慮到有沒有在我曾在github上我用下面的命令創建的存儲庫,它的工作:

git push -f origin master 
+0

我本來可以告訴你,你會告訴我你的錯誤信息 – VonC

+2

我編輯了我的答案,解釋你爲什麼必須按-f。但是,再次提出關於Stack Overflow的問題時,你不能只提到「它沒有用」。添加錯誤消息將幫助我們幫助您。 – VonC

2

如果你沒有properly setup your ssh key with GitHub,你至少可以有(你提到)HTTPS嘗試:

git remote set-url origin https://github.com/monajalal/instagram-scraper.git 

這會詢問您的用戶名(monajalal)您的GitHub賬號/密碼。

這將工作,因爲您擁有該存儲庫,這意味着您有權推送。
確保你已經在本地提交了一個提交。

git add . 
git commit -m "new commit" 

git push -u origin master 

,你可能會被迫做git push -f的事實意味着目的地(遠程GitHub庫)是不是空的,但是包括它自己的提交(通常是README.mdLICENSE文件)

在這種情況下,它是最好的,與Git 2.9 or more,要做到:

git config --global pull.rebase true 
git config --global rebase.autoStash true 

然後

git pull 

這將重播您在本地提交(以及獲取的形式)GitHub回購之上的提交。

然後,一個簡單的git push -u origin master將工作。不需要強迫你的歷史。

+0

我試着說你說的,但沒有工作。 –

+0

你收到了什麼錯誤信息? – VonC

相關問題