On Sun, 7 Aug 2005, Sam Ravnborg wrote:
> I accidently commited too many files to my tree today, and now I want to
> drop the commit so I have logically separate commits.
> What is the right way to do this - in cogito hopefully.

Not cogito, and this needs to be scripted, but if what you _want_ to do is
undo the commit (in order to re-do it as several commits), here are the
raw git commands necessary (you could make this "git-fix-script", and then
"git fix"  basically does the git equivalent of what "bk fix -C" did)

        # Set up
        . git-sh-setup-script || die "Not a git archive"

        # Figure out the parent.
        parent=$(git-rev-parse --verify HEAD^) || exit

        # Update the index to be at that point in time and make HEAD 
        # point to it, but don't update the working tree contents (ie
        # the changes remain in the working tree, to be re-committed).
        git-read-tree -f -m $parent && echo $parent > .git/HEAD

NOTE! The commit still _exists_, but the HEAD reference to it is now lost.  
If you want to save that as a broken branch, you can precede this with

        git branch broken-branch

which means that the broken point got saved off as "broken-branch".

And if you didn't do that (or if you _did_ do that, and later end up 
deciding to throw that branch away with a

        rm .git/refs/heads/broken-branch

or similar) then you can get rid of the stale and unreachable objects with
a simple "git prune".

Be careful! "git prune" _will_ throw away all the objects that it can't 
find references to. You might want to run "git-fsck-cache --full 
--unreachable" first to get an idea of what it's going to throw away.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to