npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-squasher

v1.1.0

Published

This is JS cli tool to squash many commits to a single one.

Downloads

9

Readme

Squasher

This is JS cli tool to squash many commits to a single one.

Installation

npm install -g git-squasher

or

yarn global add git-squasher

Usage

Squasher provides cli command that you can run inside of your repos.

git-squash

Using with private repos

In order to be able to use this tool with private repo you need to provide a PAT (Personal Access Token). Create a new token first using this guide, then navigate to your local repo using terminal and ad newly created token to a local config file using command:

git config user.pat [paste your token here] --local

About

Squasher uses git commands and GitHub API to get all the necessary information to provide the safest way of squashing commits.

Squashy uses last commit on your default branch (master in most cases) to reset HEAD, then it adds all the files to staged area, commits them and forcibly pushes it to origin.

You can provide Squasher different commit or branch if you'd like, the tool will ask you for that.

Also it will ensure that your branch is up-to-date and has no uncommitted changes. If it detects that your branch is outdated, script will just stop and ask you to commit changes and/or pull data from origin.

Squasher uses PR title as default commit message, if no PR exists, then you'll have to provide commit message manually. Default commit message can be overridden.

What squasher does

Preparation

There are few steps that Squasher does before squashing:

  1. Detects repo remote, owner username and repo name
  2. Detects default branch (it's master in most cases)
  3. Detects if there's a pull request using GitHub API (works both for personal and enterprise accounts)
  4. Detects latest commit on default branch (hash and commit message)
  5. Squasher will also check if you have uncommitted changes or your current working tree is below other changes

Squasher will stop immediately if your branch is outdated or has uncommitted changed

Squash info

After all the preparation it will ask you few simple questions to provide smooth squash.

  1. It will show you all the information it has: username and repo name, branch name, repo title (if any)
  2. It will prompt you that is uses default branch and will offer you to change any other if necessary. You can provide commit hash, branch name or short hash (first 7 characters from commit hash). You you're providing branch name, then Squasher will try to get latest commit on it.
  3. After that Squasher will show all the changes since selected commit and will ask you to confirm that it's OK. You need to explicitly confirm it, otherwise Squasher will stop.
  4. Squasher will ask you for commit message. It will use PR title if it exists as a default commit message. If there's no PR for the branch, then you'll have to type commit message manually

Squashing process

Now Squasher is able to squash all of your commits into single commit that will contain all the changes. This process looks like this:

  • %commit_hash% – hash to reset branch (typically – latest commit from master)
  • %commit_message% – PR title or custom commit message
  • %branch_name% – current branch name
# First Suqasher will pull changes from the server
git pull
# Now we reset branch to desired commit
git reset %commit_hash%
# Stage all changed
git add . -A
# Commit changes with default message or with one provided by user
git commit -m "%commit_message%"
# Forcibly push to origin
git push -f origin %branch_name%

If anything bad happened during squashing – Squasher will reset your branch to previous state using git reflog – it will look up point in history when reset to %commit_hash% occurred and will reset branch to one step before it.

Restrictions

  • Squasher currently doesn't work with private repos
  • Squasher will stop if you're on default branch
  • Squasher will stop if there are no changes since last %commit_hash%