Skip to content

Instantly share code, notes, and snippets.

@pyqlsa
pyqlsa / squash-feature-branch.sh
Created July 17, 2022 19:42
git squash commits on feature branch
#!/usr/bin/env bash
git checkout yourBranch
git reset $(git merge-base master $(git branch --show-current))
git add -A
git commit -m "one commit on yourBranch"
@pyqlsa
pyqlsa / squash-on-main.sh
Last active January 22, 2023 08:44
git squash commits on main branch
# this should get everything down to a single commit
#
git checkout --orphan tmp-main
git commit -m "initial commit"
# move the local branch
git branch -f main
git checkout main
# delete the temp branch
git branch -d tmp-main
# git push --force
# Repo: someuser/myframework
# Fork: superteam/myframework
# Track:
git clone https://github.com/superteam/myframework.git
cd myframework
git remote add upstream https://github.com/someuser/myframework.git
# Update:
git fetch upstream