git 推送到本地仓库
$ git add .
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
遇到了问题,根据提示的错误信息,进行尝试
$ git push --set-upstream origin master
To https://gitee.com/***/notpad.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/***/notpad.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
再一次使用推送 还是报错
$ git branch --set-upstream-to=origin/master
branch 'master' set up to track 'origin/master'.
使用git pull 获取仓库代码也显示失败
$ git push -u origin master
To https://gitee.com/***/notpad.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/***/notpad.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
后来参考了某个博主的方法,发信是远程和本地仓库内容和分支不统一导致的,发现只有read文件不一样
$ git pull --rebase origin master
From https://gitee.com/***/notpad
* branch master -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
之后进行git push 成功了
git push origin master
Enumerating objects: 636, done.
Counting objects: 100% (636/636), done.
Delta compression using up to 8 threads
Compressing objects: 100% (613/613), done.
error: RPC failed; curl 7 Recv failure: Connection was reset
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (635/635), 69.78 MiB | 368.00 KiB/s, done.
Total 635 (delta 50), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date