前言
git提交文档到GitHub老是出问题,记录下
报错
首先是常规操作更新文档,命令如下
$ git add .
$ git commit -m "add"
$ git push origin main
后面老是报这种错误,如下图
To github.com:zhenxijiabei/yuque.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:zhenxijiabei/yuque.git'
解决
查阅资料,解决如下:
$ git fetch origin main
$ git merge origin FETCH_HEAD
$ git pull --rebase origin main
后面再提交果然没有出错
效果如下:
参考:
https://blog.csdn.net/m0_63748493/article/details/125519725((fetch first)和(non-fast-forward)问题详解)
https://blog.csdn.net/midnight_time/article/details/83960843(Git连接GitHub)