https://github.com/ekarton/squash-git-commits
A shell script that allows you to squash your Git commits to a single commit relative to another branch
https://github.com/ekarton/squash-git-commits
git productivity squash-commits
Last synced: about 2 months ago
JSON representation
A shell script that allows you to squash your Git commits to a single commit relative to another branch
- Host: GitHub
- URL: https://github.com/ekarton/squash-git-commits
- Owner: EKarton
- Created: 2021-05-29T02:50:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-03T10:14:40.000Z (about 3 years ago)
- Last Synced: 2025-01-24T21:29:29.150Z (4 months ago)
- Topics: git, productivity, squash-commits
- Language: Shell
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A shell script that squashes your commits to a single commit relative to a main branch
Suppose you are working on a feature branch, and because of context-switching, your feature branch contains lots of temporary commits:

Before merging your changes to the main branch, you would like to squash all your changes to a single commit:

With this shell script, you can run:
```bash
squash-commits main 'feat: Add new header'
```It will squash all of your commits to a single commit with the commit message `feat: Add new header` right above the `main` branch!
### Installation:
1. Download the [squash-commits.sh](https://github.com/EKarton/Squash-Git-Commits/blob/main/squash-commits.sh) file to your local computer, and name the file **squash-commits.sh**
2. Create an alias of this script on your terminal by having:```bash
alias squash-commits="~/Downloads/squash-commits.sh"
```
in your `~/.bash_rc` or `~/.zshrc` file3. Reload your terminal by running ```source ~/.bash_rc``` or ```source ~/.zshrc```
4. Go to your Git repo, check out to your feature branch, and run:
```bash
squash-commits ""
```where:
* `` is the branch you want the single commit to be right above
* `` is your commit message from your code changes### Disclaimer:
I have no responsibility over any damages or loss that may occur during the execution of or usage of my shell script.