遇到过的github报错和解决方法
- 
如果輸入$ git remote add origin (github账号名)/gitdemo(项目名).git 
 提示出錯信息:fatal: remote origin already exists.
 解決办法如下:
 1、先输入$ git remote rm origin
 2、再输入$ git remote add origin(github账号名)/gitdemo(项目名).git
 3、如果输入$ git remote rm origin 还是报错的话,
 error: Could not remove config section 'remote.origin'.
 需要修改gitconfig文件的內容
 4、找到你的github的安装路径
 5、找到一個名為gitconfig的文件,找到[remote "origin"]那一行刪掉。
- 
 
- 
如果输入$ ssh -T git@github.com 
 出现错误提示: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用GitGui的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 (github账号名)/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 git@github.com:defnngj/hello-world.git //连接远程github項目
 $ git push -u origin master //将本地项目更新到github项目上去
- 
 
 
             
             
             
             
            