git-svn rebase gone horribly wrong

前端 未结 1 1697
终归单人心
终归单人心 2021-02-06 18:17

Is there a way to redo a git-svn rebase. or reset any effects by it.

In my +8000 commit git-svn repository, something went wrong after merging a branch. My local \"maste

1条回答
  •  鱼传尺愫
    2021-02-06 18:50

    There is a little bit of confusion in the terms: "HEAD" is not the same thing as "head" or "tip". "HEAD" refers to the currently checked out branch.

    Anyway. :)

    If you really want to throw away everything you've done and return your master to an exact copy of trunk, that's very simple. Assuming that master is checked out:

    git reset --hard trunk
    

    Warning: reset --hard destroys uncommitted changes.

    If you want to do advanced salvation of previous work, let me give you a very, very brief introduction to one of git's numerous safety belts: the reflog. For example, if you say

    git log -g master
    

    you'll see a list of, well, "savepoints" for master. We call this the reflog in git land. Whenever an operation changes a branch, it prepends a new savepoint to the top of that branch's reflog. In other words, if the last operation you did horribly messed up your branch, you can return your branch to what it was immediately before that operation:

    git reset --hard master@{1}
    

    That @{1} will make more sense once you look at a reflog. git also supports more flashy syntax, like @{10.minutes.ago}.

    Many more things are possible, but this should be enough to get things fixed up for now.

    0 讨论(0)
提交回复
热议问题