在git的一个develop分支上对文件修改操作,为了将此分支的修改合并到主分支上,首先在develop分支上add和commit之后切换回主分支master,在主分支master上git pull更新代码到远程库最新版本,然后git merge develop合并develop分支,会出现commit 相对于当前远程库commit版本 ahead 2两次的情况,在git push时会出现

        you are not allowed to upload merges 问题。

     

 我的解决方法:

     git reset --mixed  (commit id)  使用这个命令是commit版本回退到与远程库同一commit版本,因为这个命令会清空Staging Area(Index)和Local Repository,但会保留Working Directory。所以做的修改还是保留在工作区。

     然后再次 git add 和git commit要提交的相关文件,然后就能成功的git push上去了。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐