clean github repository history

-- Remove the history from
rm -rf .git

-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"

-- push to the github remote repos ensuring you overwrite history
git remote add origin https://github.com/<YOUR ACCOUNT>/<YOUR REPOS>.git
git push -u --force origin main 

Note: older repos may have master as the main branch

git push -u --force origin master

get rid of DS_Store files

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
echo .DS_Store >> .gitignore
git add .gitignore
git commit -m '.DS_Store banished!'

amend last commit message

You can change the most recent commit message using the git commit --amend command.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The source code is licensed under MIT.

Suggest changes

If you find any mistakes (including typos) or want to suggest changes, please feel free to edit the source file of this page on Github and create a pull request.

Citation

For attribution, please cite this work as

Haky Im (2021). Github Cheatsheet. ImLab Notes. /post/2021/06/16/github-cheatsheet/

BibTeX citation

@misc{
  title = "Github Cheatsheet",
  author = "Haky Im",
  year = "2021",
  journal = "ImLab Notes",
  note = "/post/2021/06/16/github-cheatsheet/"
}