git push code Push to origin/master was rejected

  • 没办法push,尝试先 pull 一下代码,提示如下错误
Git Pull Failed
POST git-upload-pack (225 bytes)
remote: Enumerating objects: 4, done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
warning: no common commits
From "project git url"
* branch            master     -> FETCH_HEAD
* [new branch]      master     -> origin/master
refusing to merge unrelated histories
  • 解决方法,使用如下命令,将 git 上的代码及文件拉取到本地,然后再 push
git pull origin master --allow-unrelated-histories

你可能感兴趣的:(Git)