Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by mail-b.sr.ht (Postfix) with ESMTPS id 0A620FF125 for <~sircmpwn/public-inbox@lists.sr.ht>; Thu, 19 Nov 2020 08:48:25 +0000 (UTC) X-Originating-IP: 82.234.69.236 Received: from localhost.localdomain (lan31-5-82-234-69-236.fbx.proxad.net [82.234.69.236]) (Authenticated sender: denis@laxalde.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 704AAE0009; Thu, 19 Nov 2020 08:48:23 +0000 (UTC) From: denis@laxalde.org To: ~sircmpwn/public-inbox@lists.sr.ht Cc: Denis Laxalde Subject: [PATCH git-rebase.io v2] Add a section about 'git rebase --autosquash' Date: Thu, 19 Nov 2020 09:48:13 +0100 Message-Id: <20201119084813.18886-1-denis@laxalde.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201118092428.14516-1-denis.laxalde@dalibo.com> References: <20201118092428.14516-1-denis.laxalde@dalibo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Denis Laxalde --- index.html | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/index.html b/index.html index 3be9b14..f0c92d9 100644 --- a/index.html +++ b/index.html @@ -73,6 +73,7 @@
  1. Amending your last commit
  2. Fixing up older commits
  3. +
  4. Automating interactive rebase todo list
  5. Squashing several commits into one
  6. Splitting one commit into several
  7. Reordering commits
  8. @@ -187,6 +188,42 @@ git commit -a -m"fixup greeting.txt"
    $ git log -2 --oneline
     fcff6ae (HEAD -> master) Add farewell.txt
     a479e94 Add greeting.txt
    + +

    Automating interactive rebase todo list

    +

    + The steps described above can also be performed in a more automated + manner by taking advantage of the --autosquash option + of git rebase in combination with the + --fixup option of git commit: +

    +
    git commit -a --fixup HEAD^
    +git rebase -i --autosquash HEAD~3
    +

    + This will prepare the rebase plan with commits reordered and + actions set up: +

    +
    pick 8d3fc77 Add greeting.txt
    +fixup 0b9d0bb fixup! Add greeting.txt
    +pick 2a73a77 Add farewell.txt
    +
    +# Rebase f5f19fb..0b9d0bb onto f5f19fb (3 commands)
    +#
    +# Commands:
    +# p, pick <commit> = use commit
    +# f, fixup <commit> = like "squash", but discard this commit's log message
    +        
    +

    + In addition to --fixup, the --squash + option for git commit also exists and will allow you to + edit the commit message. +

    +

    + Finally, the --autosquash option can be omitted by + setting this behavior as the default through configuration: +

    +
    git config --global rebase.autosquash true
    +

    Squashing several commits into one

    As you work, you may find it useful to write lots of commits as you -- 2.20.1