1.Proxy原因
首先如果你是在公司push代码的话,可能是因为公司内部的网络代理原因,你需要对git配置代理服务器
设置代理服务器:
第一种方法:在.gitconfig加上
http.proxy=192.268.208.18:8080
http.sslVerify=false
第二种方法:直接在命令行敲
git config --global http.proxy 192.268.208.18:8080
git config --global http.sslVerify false
解除代理配置
git config --global --unset http.proxy
2.首次远程和本地内容不一致
有些小伙伴在github上创建远程资源库时,选择了init README.md,导致在本地无法push代码到远程,git发现远程的README.md文件并没有存在本地,所以报错。
可以通过合并远程和本地的方式,让本地也包含README.md文件
git pull --rebase origin master
3.fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use git push origin HEAD:<name-of-remote-branch>
当前本地不在分支上
git push origin HEAD:<name-of-remote-branch>