{"thread":{"id":"24275","subject":"*Non*-interactive squash a range ?","startedAt":"2010-07-03T13:38:14Z","lastAt":"2010-07-05T07:00:40Z","messageCount":3,"participants":["David","Johannes Sixt","Daniele Segato"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144745","messageId":"AANLkTimTx2dVlK9KKi1nZpOadwDcfyzhE8nffCyK1Sqm@mail.gmail.com","threadId":"24275","inReplyTo":null,"subject":"*Non*-interactive squash a range ?","fromName":"David","fromEmail":"bouncingcats@gmail.com","sentAt":"2010-07-03T13:38:14Z","receivedAt":"2010-07-03T13:38:14Z","isPatch":false,"sender":{"key":"bouncingcats@gmail.com","avatar":null},"body":"Thanks for the awesome git. I have a basic question. I am subscribed\nto this list.\n\nHaving successfully used rebase -i to squash, I wonder about some\nmethod to *non*-interactively squash a sequence of intermediate\ncommits. On a local experimental branch.\n\nLets say the starting point is this branch named \"uglybranch\" with HEAD=J\n\n    E---F---G---H---I---J  <uglybranch>\n\nwhere commit G added a previously untracked file.\n\nMy desired result is this:\n\n      ------------------K  <cleanbranch>\n     /\n    E---F---G---H---I---J  <uglybranch>\n\nwhere K and J are identical worktrees.\n\nI've used rebase -i as follows:\n $ git checkout uglybranch\n $ git checkout -b cleanbranch\n $ git rebase -i E\n # used interactive editor to squash all F..J onto E to produce K, on\ncleanbranch only, uglybranch is not changed.\n\nThis gives exactly the result I want, in particular the file added at\nG is preserved, but the drawback is that the method is needlessly\ninteractive. I want a foolproof non-interactive method that achieves\nthe same result. Namely squashing *all* the commits in the range F..J\n\nI tried this which seems to work:\n $ git checkout uglybranch\n $ git checkout -b cleanbranch\n $ git reset --mixed E          # worktree same as uglybranch\n $ git add .                    # adds any untracked files\n $ git commit -a                # -a detects any removed files\n\nSo I'm thinking of using that method in a script. Have I overlooked\nanything? Is there a better way?\n"},{"id":"144798","messageId":"4C317B4B.3070100@viscovery.net","threadId":"24275","inReplyTo":"AANLkTimTx2dVlK9KKi1nZpOadwDcfyzhE8nffCyK1Sqm@mail.gmail.com","subject":"Re: *Non*-interactive squash a range ?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-07-05T06:27:23Z","receivedAt":"2010-07-05T06:27:23Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 7/3/2010 15:38, schrieb David:\n> I tried this which seems to work:\n>  $ git checkout uglybranch\n>  $ git checkout -b cleanbranch\n>  $ git reset --mixed E          # worktree same as uglybranch\n>  $ git add .                    # adds any untracked files\n>  $ git commit -a                # -a detects any removed files\n> \n> So I'm thinking of using that method in a script. Have I overlooked\n> anything? Is there a better way?\n\nUse 'reset --soft' instead of 'reset --mixed' followed by 'add .'.\n\n-- Hannes\n"},{"id":"144799","messageId":"AANLkTimVgEUofsrZ0SnCXdW3zMF0SOfup4lQBXwWXXP7@mail.gmail.com","threadId":"24275","inReplyTo":"AANLkTimTx2dVlK9KKi1nZpOadwDcfyzhE8nffCyK1Sqm@mail.gmail.com","subject":"Re: *Non*-interactive squash a range ?","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2010-07-05T07:00:40Z","receivedAt":"2010-07-05T07:00:40Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Sat, Jul 3, 2010 at 3:38 PM, David <bouncingcats@gmail.com> wrote:\n> Having successfully used rebase -i to squash, I wonder about some\n> method to *non*-interactively squash a sequence of intermediate\n> commits. On a local experimental branch.\n\n[...]\n\n> My desired result is this:\n>\n>      ------------------K  <cleanbranch>\n>     /\n>    E---F---G---H---I---J  <uglybranch>\n>\n> where K and J are identical worktrees.\n\n\nwhy don't you:\n\ngit checkout -b cleanbranch E~\n\ngit merge --squash J\n\n\nregards,\nDaniele Segato\n"}]}