git将本地内容传送到远程仓库出现![rejected] master -> master (fetch first)错误

时间:2021-10-22 23:45:25

问题:使用git push -u 远程库名 master 命令将本地提交的内容传到git远程库时出现错误:

命令: git push -u origin master

出现错误:
  To https://github.com/imjinghun/university.git
  ! [rejected] master -> master (fetch first)
  error: failed to push some refs to 'https://github.com/imjinghun/university.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将本地内容传送到远程仓库出现![rejected] master -> master (fetch first)错误

解决:使用 git push -f 命令重新传一遍就可以成功了

命令:git push -f

结果:
  Counting objects: 5739, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (5341/5341), done.
  Writing objects: 100% (5739/5739), 205.84 MiB | 40.00 KiB/s, done.
  Total 5739 (delta 1847), reused 0 (delta 0)
  remote: Resolving deltas: 100% (1847/1847), done.
  remote: warning: GH001: Large files detected. You may want to try Git Large File
  Storage - https://git-lfs.github.com.
  remote: warning: See http://git.io/iEPt8g for more information.
  remote: warning: File ed5d681ab7d6af5905bcbae56de9ee0477d9ef3b is 60.34 MB;
  this is larger than GitHub's recommended maximum file size of 50.00 MB
  To https://github.com/imjinghun/university.git
  + cd5b93f...83b3d6c master -> master (forced update)

git将本地内容传送到远程仓库出现![rejected] master -> master (fetch first)错误