本人因为上传项目, 将jar一起上传导致另一个系统拉取github项目时, 消耗特别长时间, 因此想要回到上一个版本
本人想到的方法是 : 本地仓库先回到上一个版本, 然后在重新提交到仓库, 这样做将会报错 :
$ git push origin master
To github.com:ClearlightY/Daily-java-code-record-.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:ClearlightY/Daily-java-code-record-.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.
翻译过来的意思 : 提示:更新被拒绝,因为当前分支的提示落后于提示:它的远程对应项。集成远程更改(例如提示:“git拉.”)然后再推。提示:有关详细信息,请参阅“git推送–帮助”中的“关于快速转发的注释”。
解决方法 : 参考 push本地代码到github出错
-
使用强制push的方法:
这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。$ git push -u origin master -f
-
push前先将远程repository修改pull下来
$ git pull origin master
$ git push -u origin master
-
若不想merge远程和本地修改,可以先创建新的分支:
$ git branch [name]
然后push
$ git push -u origin [name]
- Fix git “tip of your current branch is behind its remote counterpart” - 4 real-world solutions
- 无法推送到GitHub-一直说需要合并