解决git上传失败
Posted 过往将来
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决git上传失败相关的知识,希望对你有一定的参考价值。
$ git push https://gitee.com/r-git/code.git master
To https://gitee.com/r-git/code.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://gitee.com/r-git/code.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.
asus@LAPTOP-QI3F4ONG MINGW64 ~/Desktop/新建文件夹 (master)
$ ^C
asus@LAPTOP-QI3F4ONG MINGW64 ~/Desktop/新建文件夹 (master)
$ git pull --rebase https://gitee.com/r-git/code.git master
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 1.35 KiB | 51.00 KiB/s, done.
From https://gitee.com/r-git/code
- branch master -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
git提供了一种强制上传的方式:git push -f ,它会忽略版本不一致等问题,
强制将本地库上传的远程库,但是一定要谨慎使用,因为-f会用本地库覆盖掉远程库,
如果远程库上有重要更新,或者有其他同伴做的修改,也都会被覆盖,所以一定要在确定无严重后果的前提下使用此操作。
以上是关于解决git上传失败的主要内容,如果未能解决你的问题,请参考以下文章