tags:

views:

5188

answers:

2

Suppose you have:

A-B-C

Now your compilation/test fail. The fix should be merged in A. My current work-flow is like that:

$ git commit -m "fixA"

A-B-C-fixA

$ git rebase -i A~1

And squash fixA in A, result in:

A'-B-C

Question!

Is there a command to do something like

A-B-C + (index with fix for A)

$ git commit -supperdupper A

Result:

A'-B-C
+1  A: 

What you are doing is dangerous if you are sharing the branch on which you are making changes with other people. In your case, you are rewriting commit A and rebasing B and C on top of the new A, which is a completely new object. Anyone who had already pulled the old A into their repositories could end up corrupting their repository as the history in your repository will have "magically" changed. Their git would have no way of knowing that the history has been rewritten.

Because of this fact, the Git developers have intentionally not made this easy to do as you must be aware of the consequences of doing such an operation.

Martin OConnor
I am aware of the consequences, I don't want to share those commits.
elmarco
In fact, the other developer's git *would* know that the history had changed. Git's repository format guarantees that you can never "corrupt" a repository this way. The problem is more subtle than that and the recipient's git may throw up a bunch of unnecessary merge conflicts.
Greg Hewgill
The problem is shown here - http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#problems-with-rewriting-history
Martin OConnor
+3  A: 

There is no such command. You can only easily amend the most recent commit; if you want to amend a different one, you need to use git rebase, as you are already doing.

Aristotle Pagaltzis
Thank you, I'll probably continue to search for a tool, or I'll write a script or whatever, and maybe send a question on git mailing list.
elmarco