GIT cheat sheet#
Modify GIT History#
To remove commits from the history (link)
The command below opens an editor with the history of the last 6 commits. Remove lines that represent the commits you want removed
git rebase -i HEAD~6
Add the changes and run
git rebase --continue
List all authors
git shortlog -sne # Current branch git shortlog -sne --all # All branches
Modify a specific commit (link)
git rebase --interactive bbc643cd~
In the editor that opens, mark the desired commit as editable (change
picktoe).If you want to change the initial commit, best add an empty compit before and proceed as above (based on link)
git checkout --orphan empty-initial-commit git rm -r --cached . git clean -d -f git commit --allow-empty -m 'Empty initial commit' git checkout main git rebase empty-initial-commit git branch -d empty-initial-commit