Push rejected: Push master to origin/master was rejected by remote(IDEAMACGIT)

Posted shundong106

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Push rejected: Push master to origin/master was rejected by remote(IDEAMACGIT)相关的知识,希望对你有一定的参考价值。

Push rejected: Push master to origin/master was rejected by remote

  • 第一步 在IDEA的 Terminal 终端里面输入下面的指令

    git log
  • 第二步 复制第一个(也就是最新的commit_id)

    例如我的:

    commit 20a3e3efc707dcc74bb6b2fd0f1ad1ec85fe474e (HEAD -> master, origin/master, origin/HEAD)
    

    PS:复制后 英文状态下 按Q 结束阅读 log

  • 第三步 还原操作(还原到指定的commit时间点的代码)

    git reset --hard commit_id
    git push origin HEAD --force

    • 扩展
    根据–soft –mixed –hard,会对working tree和index和HEAD进行重置:
        git reset –mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
        git reset –soft:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。如果还要提交,直接commit即可
        git reset –hard:彻底回退到某个版本,本地的源码也会变为上一个版本的内容
        HEAD 最近一个提交
        HEAD^ 上一次
        <commit_id>  每次commit的SHA1值. 可以用git log 看到,也可以在页面上commit标签页里找到.
    
    commit合并:
    http://www.douban.com/note/318248317/

以上是关于Push rejected: Push master to origin/master was rejected by remote(IDEAMACGIT)的主要内容,如果未能解决你的问题,请参考以下文章

git问题--Push rejected: Push to origin/master was rejected

解决上传代码到GitHub报错Push rejected: Push to origin/master was rejected

IDEA工具上传项目报:Push rejected: Push to origin/master was rejected

Push rejected: Push master to origin/master was rejected /failed to push some refs to /git did not

Git上传项目提示Push rejected: Push to origin/master was rejected解决办法

Push rejected: Push master to origin/master was rejected by remote(IDEAMACGIT)