Tag Archives: git

How to Flatten the History of a Git Repository Safely / Squashing Commits

Squashing Commits. It’s also possible to take a series of commits and squash them down into a single commit.

Note: August 2022, as some repos have moved away from the term “master” to use “main” as the main branch – the commands below have been altered to reflect this.

git checkout --orphan future-master
git add -A # Add all files and commit them
git commit
git branch -D main # Deletes the main branch
git branch -m main # Rename the current branch to main
git push -f origin main # Force push main branch to github
git gc --aggressive --prune=all # remove the old files

Git / GitHub Must-Dos

Setting your no-reply commit email address on GitHub

https://help.github.com/articles/setting-your-commit-email-address-on-github/

git config --global user.email "username@users.noreply.github.com"

Caching your GitHub password in Git

https://help.github.com/articles/caching-your-github-password-in-git/

git config --global credential.helper 'cache --timeout 9000'