git push 时【remote rejected】 error: 无法推送一些引用到 'xxx'

! [remote rejected] branchA -> branchA (pre-receive hook declined)
error: 无法推送一些引用到 'gitlab.xxx.xxx.xxx/xxx.git'

原因推测: 

  你的commit不是当前分支最新的commit 或者是做了rebase操作造成的, 可以在本地删除有问题的分支,然后再新建刚刚删除的

解决方法

一:

1. git checkout -B onebranch-temp
2. git branch -D onebranch
3. git pull
4. git checkout onebranch
5. git branch -D onebranch-temp
6. git pull
7. git cherry-pick [git log --oneline中的哈希值]
8. git push

 

 

 

二:

1. git reset [hash], 再git push

2. git merge [主分支], 再git push

 

三:

git push -f

posted @ 2021-11-04 18:49  一路向北√  阅读(3119)  评论(0编辑  收藏  举报

web应用开发&研究 -

业精于勤而荒于嬉。

工作,使我快乐。


Font Awesome | Respond.js | Bootstrap中文网