search

Home  >  Q&A  >  body text

github - git reset 回滚的问题

我reset回first commit.
然后修改了,再提交。就不行了

更新如下,其实我只是想实现svn的功能。提取版本一,作了修改,然后push,生成了版本三,而不是直接覆盖了版本二

PHPzPHPz2801 days ago872

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-21 11:18:09

    git reset is suitable for operations in your own branch. It is not recommended to perform this operation after the branch has been merged into the remote repository.
    If the remote repository will not affect other people's update and merge (one person's remote repository), you can use git -f push to force push to the remote repository.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-21 11:18:09

    The concepts of history between svn and git are very different.
    The push operation of git is equivalent to merging the current branch into the remote branch. The operation of braised cooking is actually like this

    开始是这样:    o--o--o--o--o
    后来reset:    o
    再后来:    o
                \
                 x--x
    So Luzhui wants to merge the completely different branches since the first commit. Do you think remote can agree? If you want to merge, Luzhui can be merged under the current branch, for example

    git merge|rebase origin/current_branch #当然在与remote进行合并的时候,尽量不使用rebase这样对history有“破坏”的操作
    # 接下来解决一系列冲突
    git push ...

    Or replace the remote branch with a local branch

    git push origin current_branch -f

    It is recommended to read the book "Pro Git" in detail, it will be very helpful.

    English: http://git-scm.com/book/

    Chinese: http://git-scm.com/book/zh

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-21 11:18:09

    Use git push -f or git revert, see for details:
    git push -f

    reply
    0
  • 黄舟

    黄舟2017-04-21 11:18:09

    Deleting the remote branch directly is too violent. You can refer to the solution in this blog http://blog.mtxcxin.cn/blog/How to roll back a remote warehouse in git.html

    reply
    0
  • Cancelreply