1. 程式人生 > >解決GIT不能push程式碼到github

解決GIT不能push程式碼到github


Proxy原因

首先如果你是在公司push程式碼的話,可能是因為公司內部的網路代理原因,你需要對git配置代理伺服器

設定代理伺服器:

第一種方法:在.gitconfig加上

http.proxy=127.0.0.1:8087

http.sslVerify=false

第二種方法:直接在命令列敲

git config --global http.proxy 127.0.0.1:8087

git config --global http.sslVerify false

首次遠端和本地內容不一致

有些小夥伴在github上建立遠端資源庫時,選擇了init README.md,導致在本地無法push程式碼到遠端,git發現遠端的README.md檔案並沒有存在本地,所以報錯。

可以通過合併遠端和本地的方式,讓本地也包含README.md檔案

git pull --rebase origin master

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>