Git quick checklist

Resets all changes done

git reset --hard

Give a git commit without changing the previous commit message

git commit --amend --no-edit

Modify last commit message

git commit --amend -m "An new updated commit message"

Push to master

git push origin HEAD:refs/for/master

Discard all changes made to a file

discard changes in locally modified file

 git restore main.cpp

git delete local branch

git branch --delete old-branch

How Remove Files completely from git repository history

Sometimes it may happen that one of our team members commit unwanted files to git repo and later we may delete it. But the files are still in git history and on every clone it will consume too much bandwidth. Issue the below commands to completely delete file from git repo history.

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch filetoremove.zip -r' --prune-empty --tag-name-filter cat -- --all
 

Replace filetoremove.zip with the file you want to remove.

git push origin master --force

Push your changes to remote and try taking a new fresh clone it will take be of lesser size since the deleted files are excluded