Skip to main content

How to combine the last two commits into a single one in Git

 How to combine the last two commits into a single one in Git


If you want to squash the last two commits into one without changing the commit message, you can follow these steps:

Steps to Squash the Last Two Commits Without Changing the Commit Message


  1. Start an Interactive Rebase: Use the git rebase -i command to start an interactive rebase for the last two commits: 

    git rebase -i HEAD~2


  2. Edit the Rebase File: In the text editor that opens, you’ll see something like this:

    pick a1b2c3 First commit message
    pick d4e5f6 Second commit message

    Change the second pick to squash (or s) to indicate you want to squash it into the first commit:

    pick a1b2c3 First commit message
    squash d4e5f6 Second commit message


  3. Save and Close the Editor: After making the change, save and close the editor.


  4. Keep the Commit Message: When Git opens another editor for the commit message, it will show you both commit messages. You can simply delete the second commit message and leave the first one as is, or you can keep both messages without any modifications. If you want to keep the first commit message exactly as is, just make sure it appears correctly.

    For example, it might look like this:

    First commit message


  5. Save and Close the Editor Again: Save and close the editor again to complete the rebase.


  6. Force Push (if applicable): If you had previously pushed the original commits to the remote repository, you will need to force push the changes:

    git push origin HEAD --force




Comments

Popular posts from this blog

Highlights on my contributions to Odoo Community Association

 Highlights on my contributions to Odoo Community Association For me as a developer working on odoo community and providing services to the customers using the community version of Odoo. Sometimes the solution is available in a module published by OCA that could be an older version of Odoo. As a result, I decided to put my upgraded modules on their repositories as a contributor, and I asked to join them on the mailing list. For them, before I start to make a pull request, I need to sign their ICLA document. ICLA means Odoo Community Association Individual Contributor License Agreement. To upgrade a module to version 17.0 I had to follow the instructions stated on: https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-17.0 Firstly this section: https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-17.0#before-migrating Which needs you to: (1)      Subscribe to OCA mailing list (2)     Sign ICLA as stated above (3)     I...

How to dynamically load a JS file in JavaScript

How to dynamically load a JS file in JavaScript   https://www.educative.io/answers/how-to-dynamically-load-a-js-file-in-javascript function  loadJS ( FILE_URL ,   async   =   true )   {    let  scriptEle  =  document . createElement ( "script" );   scriptEle . setAttribute ( "src" ,   FILE_URL );   scriptEle . setAttribute ( "type" ,   "text/javascript" );   scriptEle . setAttribute ( "async" ,   async );   document . body . appendChild ( scriptEle );    // success event    scriptEle . addEventListener ( "load" ,   ()   =>   {     console . log ( "File loaded" )    });     // error event   scriptEle . addEventListener ( "error" ,   ( ev )   =>   {     console . log ( "Error on loading file" ,  ev ); ...

Create mail alias in odoo

 Create a mail alias in odoo  to solve that error: Explainn in log "create an appopriate mail.alias or force the destination model" Settings  >  Email  >  Aliases  >  add alias email to your domain name Settings >Technical > System Parameters > key: mail.bounce.alias, value: bounce Settings >Technical > System Parameters > key: mail.catchall.alias, value: catchall Settings >Technical > System Parameters > key: mail.catchall.domain, value: example.com