1、Git 提示fatal: remote origin already exists 错误解决办法
先删除远程 Git 仓库
git remote rm origin
再添加远程 Git 仓库
$ git remote add origin git@github.com:FBing/java-code-generator
如果执行 git remote rm origin 报错的话,我们可以手动修改gitconfig文件的内容
$ vi .git/config
把 [remote “origin”] 那一行删掉就好了。
2、git error: failed to push some refs to 报错和error: GH007: Your push would publish
需要在git网站(https://github.com)中设置邮箱为公开
3.Git 中使用 ping 出现乱码
在 git 窗口鼠标右键,选择 options 选项,在Text中修改 Character set 为 GBK 即可,之前是 UTF-8 格式
4.Ping github.com 超时
打开C:\Windows\System32\drivers\etc\hosts,在hosts尾部添加:
192.30.255.112 github.com git
185.31.16.184 github.global.ssl.fastly.net
保存文件时可能会提示没有权限,请百度获取文件权限的方法
参考网站:https://blog.csdn.net/hanchao5272/article/details/79393393
5.github无法访问
hosts提供了域名和IP的对应数据库,但现在github给出的IP貌似过期了,所以会访问失败
解决:把host中github相关的IP信息去掉(mac上的位置:/etc/hosts),然后执行以下命令使新的hosts生效:sudo killall -HUP mDNSResponder
参考网站:https://testerhome.com/topics/5507
6.git push 提示 Everything up-to-date
执行 git remote -v 后看到自己的 remote 端名字为 origin:
执行 git branch 后看到自己当下用的分支是 master:
去commit一个文件,再执行 git push origin master 即可ok。
参考网站:https://blog.csdn.net/jiangnan_java/article/details/21192675
7.解决GitHub commit次数过多.git文件过大的问题
完全重建版本库
$ rm -rf .git
$ git init
$ git add .
$ git cm "first commit"
$ git remote add origin <your_github_repo_url>
$ git push -f -u origin master
8.解决HTTP Basic: Access denied错误
解决: 如果你已经执行过 git clone http://git.ops.test.com.cn/root/puppet.git
,则可以进入puppet目录,修改 .git/config中url = http://账号:密码@git.ops.test.com.cn/root/puppet.git
,再提交就发现不要输入密码了;或者直接在克隆仓库的时候直接 git clone http://账号:密码@git.ops.test.com.cn/root/puppet.git
,这样下次提交时也不需要输入密码。
或者执行:git config --system --unset credential.helper
参考:https://blog.csdn.net/zhuifeng_tjy163163/article/details/80649367?utm_source=copy