Skip to content

Instantly share code, notes, and snippets.

@iamtalhaasghar
Created August 1, 2021 05:35
Show Gist options
  • Save iamtalhaasghar/057c3e8b05bd1c8fdb186e11851bbbda to your computer and use it in GitHub Desktop.
Save iamtalhaasghar/057c3e8b05bd1c8fdb186e11851bbbda to your computer and use it in GitHub Desktop.
Some commands which help you to clean your git commit history.
# Sign all previous commits
git rebase --root --exec "git commit --amend --author='Talha Asghar <talhaasghar.contact@simplelogin.fr>' --no-edit --allow-empty"
git rebase --committer-date-is-author-date --root
git push -f
# Sign all commits to-date but dont touch commits before this point in history .i.e. commit hash "SHA256HASHEXAMPLE0000"
# Replace "SHA256HASHEXAMPLE0000" with your commit hash
git rebase SHA256HASHEXAMPLE0000 --exec "git commit --amend --author='Talha Asghar <talhaasghar.contact@simplelogin.fr>' --no-edit --allow-empty"
git rebase --committer-date-is-author-date SHA256HASHEXAMPLE0000
git push -f
# to clone repos from a text file having those repos' links
while read p; do git clone "$p"; done < ~/Documents/github-cleaning/sources.txt
# to do something in subdirectories
for d in ./*/ ; do (cd "$d" && pwd); done
# search for all readmes in subdirectories
for i in $(find . -maxdepth 2 -type f -iname readme*); do echo $i;done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment