github - git reset 回滚的问题
PHPz
PHPz 2017-04-21 11:16:09
0
4
874

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

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

PHPz
PHPz

学习是最好的投资!

reply all(4)
Peter_Zhu

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.

大家讲道理

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

伊谢尔伦

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

黄舟

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template