{"thread":{"id":"22806","subject":"Looks like --amend create commit... don't understand","startedAt":"2010-02-24T21:27:32Z","lastAt":"2010-02-25T22:25:26Z","messageCount":4,"participants":["mat","Matthieu Moy","Octavio Alvarez"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"135615","messageId":"4B8599C4.1050409@gmail.com","threadId":"22806","inReplyTo":null,"subject":"Looks like --amend create commit... don't understand","fromName":"mat","fromEmail":"matthieu.stigler@gmail.com","sentAt":"2010-02-24T21:27:32Z","receivedAt":"2010-02-24T21:27:32Z","isPatch":false,"sender":{"key":"matthieu.stigler@gmail.com","avatar":null},"body":"Hi\n\nSorry for this question that might appear soo simple but I'm a little \nbit lost :-(\n\nWhen editing my code, I like to --amend it a lot between bigger commits. \nBut when looking on gitk, I see that\ngit commit blabla --amend\n\ndoes create each and every time a new commit, I mean: with git log, \nthere is only one commit, but on gitk, I see many, with the same name \nbut different revision ID.... My understanding was that it would only \nreplace, not create each time a new revision.. Could you please explain \nme where Iàm wrong and what is happening exactly?\n\nFurthermore, if I wish to delete all those intermediary amend commit, \ncan I do it? If yes, how?\n\nThanks a lot for this help!\n\nMatthieu\n"},{"id":"135618","messageId":"vpqr5oa9tu5.fsf@bauges.imag.fr","threadId":"22806","inReplyTo":"4B8599C4.1050409@gmail.com","subject":"Re: Looks like --amend create commit... don't understand","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-02-24T22:01:22Z","receivedAt":"2010-02-24T22:01:22Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"mat <matthieu.stigler@gmail.com> writes:\n\n> commits. But when looking on gitk, I see that\n> git commit blabla --amend\n>\n> does create each and every time a new commit,\n\nYes. In Git, objects (including commits) are fundamentally immutable.\nYou never modify an object, you create a new one, and usually forget\nabout the old one.\n\n> I mean: with git log,\n> there is only one commit, but on gitk, I see many, with the same name\n> but different revision ID....\n\nThe revision ID is the sha1sum of the commit content. So, if they have\ndifferent contents, they _must_ have different IDs.\n\nWhat happens is that you start with a history like\n\nA---B <- master\n\nand then try to --amend B. What happens is that you create a new B,\nsay B', and let the branch you sit on point to this new one. Like:\n\nA---B\n \\\n  `-B' <- master\n\nMost of the time, B has just become unreachable: no branch contain it,\nno tag point to it, ... so you actually see\n\nA---B' <- master\n\nand it very much looks like you just modified B.\n\nNow, if you made B reachable before your commit --amend, like by\npushing it to another repo, letting someone else pull from it, or if B\nis already part of another branch, then the situation is different.\n\nFor example, if B is already part of a branch, like this:\n\n    .---- temp-branch\n    v\nA---B---C <- master\n\nIf you do a checkout of temp-branch, then commit --amend, you end up\nin this situation :\n\nA---B---C <- master\n \\\n  `-B' <- temp-branch\n\nThe solutions:\n\n* If you already published your commit, then don't amend it. Period.\n\n* If you want to rewrite an old commit in a branch, then read about\n  \"git rebase -i\", but make sure you read all the warnings about\n  rebase before you do so.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"135696","messageId":"4B86E152.1060108@gmail.com","threadId":"22806","inReplyTo":"vpqr5oa9tu5.fsf@bauges.imag.fr","subject":"Re: Looks like --amend create commit... don't understand","fromName":"mat","fromEmail":"matthieu.stigler@gmail.com","sentAt":"2010-02-25T20:45:06Z","receivedAt":"2010-02-25T20:45:06Z","isPatch":false,"sender":{"key":"matthieu.stigler@gmail.com","avatar":null},"body":"Dear Matthieu\n\nThanks a lot for your patient help and clear explanations, it is now \nmuch clearer for me!\n\nMerci!\n\nMatthieu\n\n\nMatthieu Moy a écrit :\n> mat <matthieu.stigler@gmail.com> writes:\n>\n>   \n>> commits. But when looking on gitk, I see that\n>> git commit blabla --amend\n>>\n>> does create each and every time a new commit,\n>>     \n>\n> Yes. In Git, objects (including commits) are fundamentally immutable.\n> You never modify an object, you create a new one, and usually forget\n> about the old one.\n>\n>   \n>> I mean: with git log,\n>> there is only one commit, but on gitk, I see many, with the same name\n>> but different revision ID....\n>>     \n>\n> The revision ID is the sha1sum of the commit content. So, if they have\n> different contents, they _must_ have different IDs.\n>\n> What happens is that you start with a history like\n>\n> A---B <- master\n>\n> and then try to --amend B. What happens is that you create a new B,\n> say B', and let the branch you sit on point to this new one. Like:\n>\n> A---B\n>  \\\n>   `-B' <- master\n>\n> Most of the time, B has just become unreachable: no branch contain it,\n> no tag point to it, ... so you actually see\n>\n> A---B' <- master\n>\n> and it very much looks like you just modified B.\n>\n> Now, if you made B reachable before your commit --amend, like by\n> pushing it to another repo, letting someone else pull from it, or if B\n> is already part of another branch, then the situation is different.\n>\n> For example, if B is already part of a branch, like this:\n>\n>     .---- temp-branch\n>     v\n> A---B---C <- master\n>\n> If you do a checkout of temp-branch, then commit --amend, you end up\n> in this situation :\n>\n> A---B---C <- master\n>  \\\n>   `-B' <- temp-branch\n>\n> The solutions:\n>\n> * If you already published your commit, then don't amend it. Period.\n>\n> * If you want to rewrite an old commit in a branch, then read about\n>   \"git rebase -i\", but make sure you read all the warnings about\n>   rebase before you do so.\n>\n>   \n"},{"id":"135699","messageId":"op.u8pe8ovd4oyyg1@alvarezp-ws","threadId":"22806","inReplyTo":"4B8599C4.1050409@gmail.com","subject":"Re: Looks like --amend create commit... don't understand","fromName":"Octavio Alvarez","fromEmail":"alvarezp@alvarezp.ods.org","sentAt":"2010-02-25T22:25:26Z","receivedAt":"2010-02-25T22:25:26Z","isPatch":false,"sender":{"key":"alvarezp@alvarezp.ods.org","avatar":null},"body":"On Wed, 24 Feb 2010 13:27:32 -0800, mat <matthieu.stigler@gmail.com> wrote:\n\n> I mean: with git log, there is only one commit, but on gitk, I see many,  \n> with the same name but different revision ID.... My understanding was  \n> that it would only replace, not create each time a new revision.. Could  \n> you please explain me where Iàm wrong and what is happening exactly?\n\nTry doing \"reload\" (as opposed to just \"update\") using CTRL+F5 after you\namend in order to see only the new commits, and ignore the old ones. If\nyou have an old version of gitk, you might need to do it directly from\nthe menu.\n"}]}