git使用遇到的問題


1、上傳ssh時,服務器驗證不過:

如果電腦上有ssh key,要將就有的備份並刪除(直接刪除文件即可),如果沒有,輸入以下命令:

1 $ ssh-keygen -t rsa -C "郵件地址@youremail.com"
2 Generating public/private rsa key pair. 3 Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<回車就好>

尤其注意第三行,應該直接回車,而不是輸入自定義的文件名。然后將生成的id_rsa.pub的內容原封不動上傳到git,之后測試命令:

1 ssh -T git@github.com

選擇“yes”,輸入用戶名和密碼,提示成功!

2、error: failed to push some refs to 'https://github.com/

git push代碼時需要將遠程倉庫的文件拉下來(pull)然后push上去。

git的本地倉庫由git維護的三棵樹組成,第一棵是我的工作目錄,它持有實際文件,第二棵是緩沖區(Index),保存臨時改動,第三棵是head,指向最后提交后的結果。

1 git add <filename>

是將文件提交到緩存區,應該是“計划改動”,然后實際提交改動:

git commit -m "代碼提交信息"

這時候改動已經提交到head,但是還沒有到達遠程倉庫,調用:

1 git push origin master

則是將改動提交到遠程倉庫,如果還沒有克隆現有倉庫,並欲將倉庫連接到某個遠程服務器,可以使用如下命令添加:

git remote add origin <server>

錯誤:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
解決辦法:
Elvis@ELVIS-PC /f/gitrepo/TestJedis (master) $ git remote add origin git@gitserver:TestRedis.git Elvis@ELVIS-PC /f/gitrepo/TestJedis (master) $ git push origin master ssh: gitserver: no address associated with name fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Elvis@ELVIS-PC /f/gitrepo/TestJedis (master) $ git remote set-url origin git@github.com:afredlyj/TestRedis.git Elvis@ELVIS-PC /f/gitrepo/TestJedis (master) $ git push origin master Enter passphrase for key '/c/Users/Elvis/.ssh/id_rsa': Counting objects: 8, done. Delta compression using up to 2 threads. Compressing objects: 100% (7/7), done. Writing objects: 100% (7/7), 2.07 KiB, done. Total 7 (delta 2), reused 0 (delta 0) To git@github.com:afredlyj/TestRedis.git 7bcfb1a..b02a2fe master -> master Elvis@ELVIS-PC /f/gitrepo/TestJedis (master)
借鑒地址:http://stackoverflow.com/questions/3283717/github-no-address-associated-with-name

參考資料:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM