tags:

views:

188

answers:

1

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 "master" does not reflect anything near a complete log of trunk.

And running git svn rebase correctly fetches new revisions but then tries to apply what looks like all 8000+ commits from the svn trunk.

Are there ways to reset and make sure the HEAD of master points to HEAD of trunk?

+2  A: 

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.

Jan Krüger
I was not aware of the trunk keyword: `git reset --hard trunk`. That did the trick.
Jesper Rønn-Jensen
It's not exactly a keyword. It's just the name of the git-svn copy of SVN's trunk... or rather, the short form of the full name. You can see a full list of the short names using, for example, git branch -r.
Jan Krüger