git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Problems reverting (includes reverting a merge)
@ 2008-06-05 17:45 jenny w
  2008-06-09  8:05 ` Andreas Ericsson
  2008-06-09  9:00 ` Alex Bennee
  0 siblings, 2 replies; 3+ messages in thread
From: jenny w @ 2008-06-05 17:45 UTC (permalink / raw)
  To: git

Someone made a few commits that I'm trying to revert. There are three
commits in a row, the middle of which is a merge. There are presently
no commits following the ones that we want to revert.

I tried git revert on the latest commit and that worked fine.

The second latest commit was a merge, so I had to use the -m switch.
I'm not exactly sure what the parent-number refers to, so I created a
separate branch to try things out. Since it expects I a number, I
started from 1. That was kind of a disaster, so I deleted my branch
and made another off of master, and then tried doing the same command
with -m 2. This worked fine.  However ...

I then tried to revert the next commit. This said there's a conflict.
Since there are no other commits after the ones I'm trying to revert,
this makes me think I'm doing something wrong ... shouldn't it just be
able to roll back?

What I'd really like to do is just zap the last 3 commits ... is there
another way to just make things the way they were before these patches
were applied?

Any help with any of the above would be greatly appreciated!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems reverting (includes reverting a merge)
  2008-06-05 17:45 Problems reverting (includes reverting a merge) jenny w
@ 2008-06-09  8:05 ` Andreas Ericsson
  2008-06-09  9:00 ` Alex Bennee
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Ericsson @ 2008-06-09  8:05 UTC (permalink / raw)
  To: jenny w; +Cc: git

jenny w wrote:
> Someone made a few commits that I'm trying to revert. There are three
> commits in a row, the middle of which is a merge. There are presently
> no commits following the ones that we want to revert.
> 
> I tried git revert on the latest commit and that worked fine.
> 
> The second latest commit was a merge, so I had to use the -m switch.
> I'm not exactly sure what the parent-number refers to, so I created a
> separate branch to try things out. Since it expects I a number, I
> started from 1. That was kind of a disaster, so I deleted my branch
> and made another off of master, and then tried doing the same command
> with -m 2. This worked fine.  However ...
> 
> I then tried to revert the next commit. This said there's a conflict.
> Since there are no other commits after the ones I'm trying to revert,
> this makes me think I'm doing something wrong ... shouldn't it just be
> able to roll back?
> 
> What I'd really like to do is just zap the last 3 commits ... is there
> another way to just make things the way they were before these patches
> were applied?
> 

git diff HEAD~3 | git apply -R && git commit <relevant files>

Although that will revert all 3 of them in one go, but perhaps that's
ok? Oh, and it won't work unless the merge-parent you want to revert
is the "first" parent (a straight line to the left when viewed in gitk
or qgit).

If you haven't published the commits anywhere yet, you can do

	git reset --hard HEAD~3

Note that this will clobber your worktree though, so use with caution.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems reverting (includes reverting a merge)
  2008-06-05 17:45 Problems reverting (includes reverting a merge) jenny w
  2008-06-09  8:05 ` Andreas Ericsson
@ 2008-06-09  9:00 ` Alex Bennee
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Bennee @ 2008-06-09  9:00 UTC (permalink / raw)
  To: jenny w; +Cc: git

On Thu, 2008-06-05 at 10:45 -0700, jenny w wrote:

> What I'd really like to do is just zap the last 3 commits ... is there
> another way to just make things the way they were before these patches
> were applied?

Wouldn't git-reset --hard HEAD^^^ do what you want. It will rewind your
tree to 3 commits bellow the current head, the --hard ensure your
working tree is cleared out as well.

> 
> Any help with any of the above would be greatly appreciated!
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Alex, homepage: http://www.bennee.com/~alex/
Envy is a pain of mind that successful men cause their neighbors. --
Onasander

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-09  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-05 17:45 Problems reverting (includes reverting a merge) jenny w
2008-06-09  8:05 ` Andreas Ericsson
2008-06-09  9:00 ` Alex Bennee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).