本人因为上传项目, 将jar一起上传导致另一个系统拉取github项目时, 消耗特别长时间, 因此想要回到上一个版本
本人想到的方法是 : 本地仓库先回到上一个版本, 然后在重新提交到仓库, 这样做将会报错 :
翻译过来的意思 : 提示:更新被拒绝,因为当前分支的提示落后于提示:它的远程对应项。集成远程更改(例如提示:“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-一直说需要合并