{"thread":{"id":"19286","subject":"merging multiple commit into one?","startedAt":"2009-05-11T13:21:27Z","lastAt":"2009-05-12T20:37:09Z","messageCount":10,"participants":["jean-luc malet","Andreas Ericsson","Jakub Narebski","Heiko Voigt","MALET Jean-Luc","Markus Heidelberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"113536","messageId":"1de9d39c0905110621p6858bca8y8bb036a167754672@mail.gmail.com","threadId":"19286","inReplyTo":null,"subject":"merging multiple commit into one?","fromName":"jean-luc malet","fromEmail":"jeanluc.malet@gmail.com","sentAt":"2009-05-11T13:21:27Z","receivedAt":"2009-05-11T13:21:27Z","isPatch":false,"sender":{"key":"jeanluc.malet@gmail.com","avatar":null},"body":"Hi,\nI often commit \"useless\" code, for example before going into weekend\nor for saving some state during a dev process\noften thoses commit are simply useless and the commit message looks\nlike \"COMPILE ERROR - temporary save .... \"\nat the end I have LOT of theses commits that are useless and I want to\nsave some space/time/tree complexity merge multiple sequential commits\n(without branch) into one\nis it possible?\naccording to my knowledge of git, removing the commit and rewriting\nthe last commit log so that it better reflect the modification will do\nthe job but I'm not sure git allow it...\nthanks\nJLM\n\n-- \nKISS! (Keep It Simple, Stupid!)\n(garde le simple, imbécile!)\n\"mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses\nsimples et qui marchent, espèce d'imbécile!\"\n-----------------------------\n\"Si vous pensez que vous êtes trop petit pour changer quoique ce soit,\nessayez donc de dormir avec un moustique dans votre chambre.\" Betty\nReese\nhttp://www.grainesdechangement.com/citations.htm\n"},{"id":"113537","messageId":"4A0828CA.3060405@op5.se","threadId":"19286","inReplyTo":"1de9d39c0905110621p6858bca8y8bb036a167754672@mail.gmail.com","subject":"Re: merging multiple commit into one?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2009-05-11T13:31:54Z","receivedAt":"2009-05-11T13:31:54Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"jean-luc malet wrote:\n> Hi,\n> I often commit \"useless\" code, for example before going into weekend\n> or for saving some state during a dev process\n> often thoses commit are simply useless and the commit message looks\n> like \"COMPILE ERROR - temporary save .... \"\n> at the end I have LOT of theses commits that are useless and I want to\n> save some space/time/tree complexity merge multiple sequential commits\n> (without branch) into one\n> is it possible?\n> according to my knowledge of git, removing the commit and rewriting\n> the last commit log so that it better reflect the modification will do\n> the job but I'm not sure git allow it...\n> thanks\n\n\ngit commit --amend; # to extend last commit only\ngit merge --squash; # I think. Not sure though, so read the docs\ngit rebase -i; # replace \"pick\" with \"squash\" to combine commits.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nRegister now for Nordic Meet on Nagios, June 3-4 in Stockholm\n http://nordicmeetonnagios.op5.org/\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"113539","messageId":"m38wl3n3zj.fsf@localhost.localdomain","threadId":"19286","inReplyTo":"1de9d39c0905110621p6858bca8y8bb036a167754672@mail.gmail.com","subject":"Re: merging multiple commit into one?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-11T13:50:15Z","receivedAt":"2009-05-11T13:50:15Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"jean-luc malet <jeanluc.malet@gmail.com> writes:\n\n> Hi,\n> I often commit \"useless\" code, for example before going into weekend\n> or for saving some state during a dev process\n> often thoses commit are simply useless and the commit message looks\n> like \"COMPILE ERROR - temporary save .... \"\n> at the end I have LOT of theses commits that are useless and I want to\n> save some space/time/tree complexity merge multiple sequential commits\n> (without branch) into one\n> is it possible?\n\nIt is possible; one solution would be to use \"git rebase --interactive\"\nand its 'squash' command...\n\n> according to my knowledge of git, removing the commit and rewriting\n> the last commit log so that it better reflect the modification will do\n> the job but I'm not sure git allow it...\n\n...but you can simply pick up where you saved snapshot by using \"git\ncommit --amend\" (or doing soft or mixed reset to previous commit\nbefore comitting changes).\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"113592","messageId":"20090511212923.GA19844@macbook.lan","threadId":"19286","inReplyTo":"1de9d39c0905110621p6858bca8y8bb036a167754672@mail.gmail.com","subject":"Re: merging multiple commit into one?","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-05-11T21:29:24Z","receivedAt":"2009-05-11T21:29:24Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Mon, May 11, 2009 at 03:21:27PM +0200, jean-luc malet wrote:\n> according to my knowledge of git, removing the commit and rewriting\n> the last commit log so that it better reflect the modification will do\n> the job but I'm not sure git allow it...\n\nIf you just want to get rid of the last commit\n\n  git reset HEAD^\n\nwill remove the commit but keep your working directory untouched. In\nsuch a workflow I find it easier to start the new commit from zero than\nfrom the stashed stuff.\n\nBy the way. You might also take a look at the command\n\n  git stash\n\nwhich is especially crafted for saving work in progress.\n\ncheers Heiko\n"},{"id":"113596","messageId":"4A08A28C.3020202@gmail.com","threadId":"19286","inReplyTo":"20090511212923.GA19844@macbook.lan","subject":"Re: merging multiple commit into one?","fromName":"MALET Jean-Luc","fromEmail":"jeanluc.malet@gmail.com","sentAt":"2009-05-11T22:11:24Z","receivedAt":"2009-05-11T22:11:24Z","isPatch":false,"sender":{"key":"jeanluc.malet@gmail.com","avatar":null},"body":"Heiko Voigt wrote:\n> On Mon, May 11, 2009 at 03:21:27PM +0200, jean-luc malet wrote:\n>   \n>> according to my knowledge of git, removing the commit and rewriting\n>> the last commit log so that it better reflect the modification will do\n>> the job but I'm not sure git allow it...\n>>     \n>\n> If you just want to get rid of the last commit\n>\n>   git reset HEAD^\n>\n> will remove the commit but keep your working directory untouched. In\n> such a workflow I find it easier to start the new commit from zero than\n> from the stashed stuff.\n>\n> By the way. You might also take a look at the command\n>\n>   git stash\n>\n> which is especially crafted for saving work in progress.\n>\n> cheers Heiko\n>   \nhi,\nthanks, I know about git stash, the problem is that this command don't \nfits well when working on multiple copies of the sources on different \nlocations, git stash is usefull for saving states before branching \nelsewhere and comming back to the branch and keep going on your work.... \nI use it in a different way since I  commit to continue work on a \ndifferent pc, (so I commit, I push to some git archive, I pull from the \nother pc, and continue the work on the other pc, then commit push again \nand pull again on first pc....). As far as I know you can't push stashed \ninformation, I'm wrong?\nthanks\nJLM\n"},{"id":"113595","messageId":"4A08A291.2060009@gmail.com","threadId":"19286","inReplyTo":"m38wl3n3zj.fsf@localhost.localdomain","subject":"Re: merging multiple commit into one?","fromName":"MALET Jean-Luc","fromEmail":"jeanluc.malet@gmail.com","sentAt":"2009-05-11T22:11:29Z","receivedAt":"2009-05-11T22:11:29Z","isPatch":false,"sender":{"key":"jeanluc.malet@gmail.com","avatar":null},"body":"Jakub Narebski wrote:\n> jean-luc malet <jeanluc.malet@gmail.com> writes:\n>\n>   \n>> Hi,\n>> I often commit \"useless\" code, for example before going into weekend\n>> or for saving some state during a dev process\n>> often thoses commit are simply useless and the commit message looks\n>> like \"COMPILE ERROR - temporary save .... \"\n>> at the end I have LOT of theses commits that are useless and I want to\n>> save some space/time/tree complexity merge multiple sequential commits\n>> (without branch) into one\n>> is it possible?\n>>     \n>\n> It is possible; one solution would be to use \"git rebase --interactive\"\n> and its 'squash' command...\n>\n>   \n>> according to my knowledge of git, removing the commit and rewriting\n>> the last commit log so that it better reflect the modification will do\n>> the job but I'm not sure git allow it...\n>>     \n>\n> ...but you can simply pick up where you saved snapshot by using \"git\n> commit --amend\" (or doing soft or mixed reset to previous commit\n> before comitting changes).\n>\n>   \nhi! thanks for your answers!\nI didn't knew about --amend for commit, will certainly use it...\nhowever it seems that I get missunderstood...\nA-o-o-o-o-o-B-o-o-o-o-C\n                      \\-o-o-D-/\nlet say I have the above tree, o are temporary unbuildable commits, A B \nC D are usable versions\nI want as posteriory remove the o to get the following tree\nA-B---C\n     \\-D/\nin fact I just wanna clean a little my tree since I forgot to amend ;)\nis this possible?\nok I know, the best is to prevent! not to cure! so I'll amend ;)\nthanks\nJLM\n"},{"id":"113599","messageId":"200905120036.06965.jnareb@gmail.com","threadId":"19286","inReplyTo":"4A08A291.2060009@gmail.com","subject":"Re: merging multiple commit into one?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-11T22:36:06Z","receivedAt":"2009-05-11T22:36:06Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Tue, 12 May 2009, MALET Jean-Luc wrote:\n> Jakub Narebski wrote:\n>> jean-luc malet <jeanluc.malet@gmail.com> writes:\n\n>>> I often commit \"useless\" code, for example before going into weekend\n>>> or for saving some state during a dev process\n>>> often thoses commit are simply useless and the commit message looks\n>>> like \"COMPILE ERROR - temporary save .... \"\n>>> at the end I have LOT of theses commits that are useless and I want to\n>>> save some space/time/tree complexity merge multiple sequential commits\n>>> (without branch) into one\n>>> is it possible?\n     \n>>\n>> It is possible; one solution would be to use \"git rebase --interactive\"\n>> and its 'squash' command...\n\n   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   \n>>> according to my knowledge of git, removing the commit and rewriting\n>>> the last commit log so that it better reflect the modification will do\n>>> the job but I'm not sure git allow it...\n>>>     \n>>\n>> ...but you can simply pick up where you saved snapshot by using \"git\n>> commit --amend\" (or doing soft or mixed reset to previous commit\n>> before comitting changes).\n>>\n>>   \n> hi! thanks for your answers!\n> I didn't knew about --amend for commit, will certainly use it...\n> however it seems that I get missunderstood...\n> A-o-o-o-o-o-B-o-o-o-o-C\n>                       \\-o-o-D-/\n> let say I have the above tree, o are temporary unbuildable commits, A B \n> C D are usable versions\n> I want as posteriory remove the o to get the following tree\n> A-B---C\n>      \\-D/\n> in fact I just wanna clean a little my tree since I forgot to amend ;)\n> is this possible?\n> ok I know, the best is to prevent! not to cure! so I'll amend ;)\n\nAs I wrote above, you can use interactive rebase to clean up history.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"113645","messageId":"20090512155301.GA21556@macbook.lan","threadId":"19286","inReplyTo":"4A08A28C.3020202@gmail.com","subject":"Re: merging multiple commit into one?","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-05-12T15:53:15Z","receivedAt":"2009-05-12T15:53:15Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Tue, May 12, 2009 at 12:11:24AM +0200, MALET Jean-Luc wrote:\n> hi,\n> thanks, I know about git stash, the problem is that this command don't  \n> fits well when working on multiple copies of the sources on different  \n> locations, git stash is usefull for saving states before branching  \n> elsewhere and comming back to the branch and keep going on your work....  \n> I use it in a different way since I  commit to continue work on a  \n> different pc, (so I commit, I push to some git archive, I pull from the  \n> other pc, and continue the work on the other pc, then commit push again  \n> and pull again on first pc....). As far as I know you can't push stashed  \n> information, I'm wrong?\n\nAFAIR, git stash cannot be pushed. Well you could by creating a branch\nand pushing that but thats not native stash functionality.\n\ncheers Heiko\n"},{"id":"113648","messageId":"1de9d39c0905120859r67a04376g99092d3e8c1403a9@mail.gmail.com","threadId":"19286","inReplyTo":"200905120036.06965.jnareb@gmail.com","subject":"Re: merging multiple commit into one?","fromName":"jean-luc malet","fromEmail":"jeanluc.malet@gmail.com","sentAt":"2009-05-12T15:59:42Z","receivedAt":"2009-05-12T15:59:42Z","isPatch":false,"sender":{"key":"jeanluc.malet@gmail.com","avatar":null},"body":"hello\nseems that I don't use the right way....\nI chechouted my lastest branch, then do a git rebase --interactive\n9ce8f6940a50d87e4f6503ff237bd1b1ff560660\nwhere 9ce8f6940a50d87e4f6503ff237bd1b1ff560660 is the commit I want to start...\nI modified the file and marked the commit I wanted to squash... and\nwell it keep continue to find me conflicts.... even where there shall\nnot be\n\nso I said I have to start from the root and rebase my branch on it....\ncreated a branch on root, checkout it, git rebase --interactive\nb52ea8c36188b05de246d5717781ab90710078d5\nhuh?! nothing to do... ok fine\n\nso I tried to put branch just after the nodes I wanted to squash....\nand git rebase --interactive thesha1rigthbeforewhatiwantedtosquash....\nah! here it works! huh?! well quite not! it replayed the range of\ncommit fine, removed the squashed one... fine... but do created\nanother independant branch... what I don't want I just want to remove\na set inside the current tree\nso I'm not doing it right?\n\nthanks\nJLM\n\nOn Tue, May 12, 2009 at 12:36 AM, Jakub Narebski <jnareb@gmail.com> wrote:\n> On Tue, 12 May 2009, MALET Jean-Luc wrote:\n>> Jakub Narebski wrote:\n>>> jean-luc malet <jeanluc.malet@gmail.com> writes:\n>\n>>>> I often commit \"useless\" code, for example before going into weekend\n>>>> or for saving some state during a dev process\n>>>> often thoses commit are simply useless and the commit message looks\n>>>> like \"COMPILE ERROR - temporary save .... \"\n>>>> at the end I have LOT of theses commits that are useless and I want to\n>>>> save some space/time/tree complexity merge multiple sequential commits\n>>>> (without branch) into one\n>>>> is it possible?\n>\n>>>\n>>> It is possible; one solution would be to use \"git rebase --interactive\"\n>>> and its 'squash' command...\n>\n>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n>\n>>>> according to my knowledge of git, removing the commit and rewriting\n>>>> the last commit log so that it better reflect the modification will do\n>>>> the job but I'm not sure git allow it...\n>>>>\n>>>\n>>> ...but you can simply pick up where you saved snapshot by using \"git\n>>> commit --amend\" (or doing soft or mixed reset to previous commit\n>>> before comitting changes).\n>>>\n>>>\n>> hi! thanks for your answers!\n>> I didn't knew about --amend for commit, will certainly use it...\n>> however it seems that I get missunderstood...\n>> A-o-o-o-o-o-B-o-o-o-o-C\n>>                       \\-o-o-D-/\n>> let say I have the above tree, o are temporary unbuildable commits, A B\n>> C D are usable versions\n>> I want as posteriory remove the o to get the following tree\n>> A-B---C\n>>      \\-D/\n>> in fact I just wanna clean a little my tree since I forgot to amend ;)\n>> is this possible?\n>> ok I know, the best is to prevent! not to cure! so I'll amend ;)\n>\n> As I wrote above, you can use interactive rebase to clean up history.\n>\n> --\n> Jakub Narebski\n> Poland\n>\n\n\n\n-- \nKISS! (Keep It Simple, Stupid!)\n(garde le simple, imbécile!)\n\"mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses\nsimples et qui marchent, espèce d'imbécile!\"\n-----------------------------\n\"Si vous pensez que vous êtes trop petit pour changer quoique ce soit,\nessayez donc de dormir avec un moustique dans votre chambre.\" Betty\nReese\nhttp://www.grainesdechangement.com/citations.htm\n"},{"id":"113689","messageId":"200905122237.10173.markus.heidelberg@web.de","threadId":"19286","inReplyTo":"20090512155301.GA21556@macbook.lan","subject":"Re: merging multiple commit into one?","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-05-12T20:37:09Z","receivedAt":"2009-05-12T20:37:09Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Heiko Voigt, 12.05.2009:\n> On Tue, May 12, 2009 at 12:11:24AM +0200, MALET Jean-Luc wrote:\n> > As far as I know you can't push stashed  \n> > information, I'm wrong?\n> \n> AFAIR, git stash cannot be pushed. Well you could by creating a branch\n> and pushing that but thats not native stash functionality.\n\nI tried \"git clone --mirror\" with a repo containing a stash, the clone\nhad a stash entry in .git/packed-refs. \"git push --mirror\" didn't work,\nthough. Not sure what should be intended.\n\nMarkus\n"}]}