Hi David,

On 2013-11-04, David Roe <roed.m...@gmail.com> wrote:
> Even if you
> decide you don't want some code that you introduced, you should introduce a
> new commit that deletes the code rather than removing old commits and
> force-pushing your branch.

Good example.

So, what simple and easy-to-use command does git offer to create a
"negative commit"? That's to say, if I have commits A-B-C and want to
"remove" B, how can I make git create a commit D for me such that
A-B-C-D results in the same code as A-C?

If the creation of D is more complicated than changing the "apply"
information on trac (for patches in the old workflow, I mean), I still
don't see why I should do so, from the point of view of "avoid dull work".

Anyway, I think it is a good idea to have a concrete
example. I created a test repository, created ticket/123,
ticket/456 and an identical copy ticket/456new of ticke/456.

The commits are
- A: Introduces file bla
- B: Introduces file blaB
- C: Changes file bla
- X: Changes file bla on top of commit C

Branches master and ticket/123 is A-B-C, branches ticket/456 and
ticket/456new are A-B-C-X

Result on ticket/123 = master
  git log --oneline
    202a495 Commit C
    c7edaa0 Commit B
    3c00aaf Commit A
  ls
    bla blaB

Then, I changed ticket/123 by
  git reset --hard HEAD~2
followed by 
  git cherry-pick master

The result was
  git log --oneline
    e7d13cf Commit C
    3c00aaf Commit A
  ls
    bla

Then, I tested two ways to rebase ticket/456 resp ticket/456new with
respect to the changed branch ticket/123.

First way:
  git checkout ticket/456
  git merge ticket/123
  <resolve merge conflicts>
which resulted in
  git log --oneline
    063383d Merge branch 'ticket/123' into ticket/456
    e7d13cf Commit C
    007abaf Commit X
    202a495 Commit C
    c7edaa0 Commit B
    3c00aaf Commit A
and
  ls
    bla  blaB

This is certainly not what we want.

Second way:
  git rebase ticket/123 ticket/456new
  <it simply worked, no conflicts!>
which resulted in
  git log --oneline
    3816d11 Commit X
    9f83a92 Commit B
    e7d13cf Commit C
    3c00aaf Commit A
and
  ls
    bla  blaB

This is also certainly not what we want.

Question to the git experts:
- Is there an easy git command that creates a new commit reverting the
  effects of a specified old commit (or series of old commits)?

If there isn't, I think it is a good argument for using patches and
mercurial queues. If you have patches A,B,C,X corresponding to the commits
above, then removing B simply amounts to hg qdelete B.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to