【git报错】hint: Updates were rejected because the tip of your current branch is behind


有时候作为非master权限的项目参与者

在push的时候会遇到这样的报错:

hint: Updates were rejected because the tip of your current branch is behind

由于push的操作,本质上是用本地的最新版本,去覆盖远程仓库中某个分支的上一个版本,一般默认是master分支

此时就会由于不具备操作master分支的权限而报这个错误

 

解决方法很简单:

1)像很多帖子说的一样加一个强制参数-f

git push -u origin master -f

但这个是很危险的,因为会覆盖掉受保护的master分支

所以推荐以下做法

 

2)新建一个分支

git branch [new_branch_name]

然后push给这个新的branch


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM