GitHub使用过程中遇到的坑(已解决)
GitHub使用过程中遇到的坑(已解决)
- 1、错误 ! [rejected] master -> master (non-fast-forward)
- 强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容
- 2,先把git的东西fetch到你本地然后merge后再push
- 2、fatal: remote origin already exists.
- 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.
1、错误 ! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘git@github.com:Try-your-best-to-do/Myjava.git’
hin
问题(Non-fast-forward)的出现原因在于:git仓库中已经有一部分代码,所以它不允许你直接把你的代码覆盖上去。
1. 强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容
git push -f
2,先把git的东西fetch到你本地然后merge后再push
$ git fetch
$ git merge
这2句命令等价于
$ git pull
2、fatal: remote origin already exists.
解决办法如下:
1、先输入$ git remote rm origin
2、再输入$ git remote add origin git@github.com:(github帐号名)/(项目名).git
就不会报错了!
3、如果输入$ git remote rm origin
还是报错的话,error: Could not remove config section ‘remote.origin’. 我们需要修改 gitconfig 文件的内容
4、找到你的 github 的安装路径
5、找到一个名为gitconfig的文件,打开它把里面的[remote “origin”]那一行删掉就好了!
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.
解决:
则需要重新输入$ git remote add origin git@github.com:(github帐号名)/(项目名).git
注意是GitHub的账户名,我一直写到配置时的 username 所以一直没有解决!!!
参考链接:
https://www.jianshu.com/p/feb3a14c24ef
https://blog.csdn.net/su1573/article/details/78282813
https://www.jianshu.com/p/8d26730386f3
https://www.runoob.com/w3cnote/git-guide.html
还没有评论,来说两句吧...