Git Useful Commands

Remove last commit

git reset --hard HEAD~1

Remove last commit but keep files

git reset --soft HEAD~1

Delete a local branch

git branch --delete <branch>
git branch -d <branch> # Short version
git branch -D <branch> # Force delete un-merged branch

Delete a remote branch

 git push origin --delete <branch>
 git push origin:<branch>
 git push --delete <remote_name> <branch_name>

Random Useful Commands

git rebase -i HEAD~3
git fetch && git rebase origin/main
git reset --hard origin/branch

git fetch origin branch
git reset --hard FETCH_HEAD