Github上傳專案步驟和常見問題
阿新 • • 發佈:2019-01-03
一些可能遇到的問題解決:
如果輸入$ git remote add origin [email protected]:djqiang(github帳號名)/gitdemo(專案名).git
提示出錯資訊:fatal: remote origin already exists.
解決辦法如下:
1、先輸入$ git remote rm origin
2、再輸入$ git remote add origin [email protected]:djqiang/gitdemo.git 就不會報錯了!
3、如果輸入$ git remote rm origin 還是報錯的話,error: Could not remove config section ‘remote.origin’. 我們需要修改gitconfig檔案的內容
4、找到你的github的安裝路徑,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
5、找到一個名為gitconfig的檔案,開啟它把裡面的[remote "origin"]那一行刪掉就好了!
如果輸入$ ssh -T [email protected]
出現錯誤提示:Permission denied (publickey).因為新生成的key不能加入ssh就會導致連線不上github。
解決辦法如下:
1、先輸入$ ssh-agent,再輸入$ ssh-add ~/.ssh/id_key,這樣就可以了。
2、如果還是不行的話,輸入ssh-add ~/.ssh/id_key 命令後出現報錯Could not open a connection to your authentication agent.解決方法是key用Git Gui的ssh工具生成,這樣生成的時候key就直接儲存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令列來做。
3、最好檢查一下在你複製id_rsa.pub檔案的內容時有沒有產生多餘的空格或空行,有些編輯器會幫你新增這些的。
如果輸入$ git push origin master
提示出錯資訊:error:failed to push som refs to …….
解決辦法如下:
1、先輸入$ git pull origin master //先把遠端伺服器github上面的檔案拉下來
2、再輸入$ git push origin master
3、如果出現報錯 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository.
4、則需要重新輸入$ git remote add [email protected]:djqiang/gitdemo.git
使用git在本地建立一個專案的過程
$ makdir ~/hello-world //建立一個專案hello-world
$ cd ~/hello-world //開啟這個專案
$ git init //初始化
$ touch README
$ git add README //更新README檔案
$ git commit -m ‘first commit’ //提交更新,並註釋資訊“first commit”
$ git remote add origin [email protected]:defnngj/hello-world.git //連線遠端github專案
$ git push -u origin master //將本地專案更新到github專案上去
error: RPC failed; result=52, HTTP code = 0fatal: The remote end hung up unexpectedly 應該是pull 內容更新太多,需要設定postBuffer更大些,具體看下面的連結 git config --global http.postBuffer 524288000