HomeToolsAbout a20k

Commit History and Resetting History

git log

# Show all previous commit message and hash git log # Show the last n-commit message and hash git log -n

git reflog

# Look at the history of the git operations performed at `HEAD` git reflog # view detailed action history of all branches (incl. stash) git reflog -all

Start a New Git History

Squashing every change up until current changes.

Create a new orphan branch at the tip (i.e. the most recent commit) of your current branch

  • This orphan branch forms the initial root commit of an entirely new and separate commit history tree, which is effectively equivalent to squashing all commits
git checkout --orphan new-master master git commit -m "new initial commit" # Overwrite the old master branch reference with the new one git branch -M new-master master
© VincentVanKoh