git操作之常见问题解决方案

时间:2023-12-18 15:49:38

一、版本不一致

  1. 错误信息:    

 > git push -u origin master
To ******.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '*******.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.

  2. 错误原因: 本地和远程两个版本不一致。

  3. 解决方案: git push -u origin -f

  4. 注: 加'-f'的意思是-强制推送本地的替换服务端, 所以三思后行。

未完待续...