Can git commits be squashed from a node.js script?

I would like to be able to squash the last n commits that have a commit message of ‘squash commit’ into a single commit from a node.js script. The only way that I know of to squash commits is through an interactive rebase, is there a way to do this from a node script?

Ex:

  • How to view file contents as it was in a commit - Like `git show`
  • How can I see the list of all commits that affect a specific file with git (including orphaned or dangling commits)
  • Removing a useless commit with rebase gives error
  • Running git pull from a php script
  • AWS EB Deploy ERROR: Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 18
  • cant see git folders in windows even though Ive it set to show hidden files
  • > git log --oneline | head -4
    ecce153 Do not change commit
    dd831f6 squash commit
    c20677a squash commit
    86b52fb squash commit
    
    > ./squash.js "New commit made by squashing 3 'squash commit' commits."
    ecce153 Do not change commit
    as34dwf New commit made by squashing 3 'squash commit' commits.
    

    Going off of this SO post, https://stackoverflow.com/a/5956198/626759, I could get to the interactive rebase easily enough, but how could I work with that from a node script?

    Thanks.

  • Heroku push master ssh problem
  • How to tell git to ignore certain folders and files during a subtree merge?
  • Git tags don't show up as GitHub releases
  • Why do you use Git over Mercurial? (Or vice versa.)
  • Magento upgrading with Git
  • Github fork and branch
  • One Solution collect form web for “Can git commits be squashed from a node.js script?”

    You don’t need to do a rebase to squash n commits:

    git reset HEAD~4
    git add .
    git commit -m "squashed four commits"
    

    This backs up HEAD four commits, but preserves the present changes in the working directory, then adds and commits those changes in a single commit.

    Even shorter version

    git reset --soft HEAD~4
    git commit -m "squashed four commits"
    

    --soft preserves the index too, so you don’t have to add.

    Git Baby is a git and github fan, let's start git clone.