1. 程式人生 > >Git遠端庫操作遇到的一些問題

Git遠端庫操作遇到的一些問題

一、問題:執行git remote add origin [email protected]:yylxm/Git.git

                    出現問題fatal: remote origin already exists.

        解決辦法:git remote顯示所有的遠端庫,然後採用git remote rm origin刪除該origin。

二、問題: 採用git push -u origin master推送本地庫到github
                   出現問題fatal: I don't handle protocol '[email protected]

'

       解決辦法:採用git remote add origin http://github.com:yylxm/Git.git,Git.git是在github上建立的repositories 。


三、問題:執行$ git push -u origin master
                   出現問題 Username for 'https://github.com': yylxm
                                    To https://github.com/yylxm/YYXQZ.git
                                     ! [rejected]        master -> master (fetch first)
                                    error: failed to push some refs to 'https://github.com/yylxm/YYXQZ.git'
                                    hint: Updates were rejected because the remote contains work that you do
                                    hint: not have locally. This is usually caused by another repository pushing
                                    hint: to the same ref. You may want to first integrate the remote changes
                                    hint: (e.g., 'git pull ...') before pushing again.
                                    hint: See the 'Note about fast-forwards' in 'git push --help' for details.

      解決辦法:錯誤的主要原因是github中的README.md檔案不在原生代碼目錄中,

                         可以通過如下命令進行程式碼合併【注:pull=fetch+merge】 git pull --rebase origin master

                         再通過命令git push -u origin master完成程式碼上傳到github的操作。