1. Git to discard uncommitted changes in your working directory
git restore .
  1. Moves the last commit back to the staging area (index), keeping all changes.
git reset --soft HEAD~
  1. Moves the last commit back to the staging area (index), Discard all changes.
git reset --hard HEAD~
  1. Deletes a local branch named branch_name.
git branch -d branch_name
  1. Force Delete a Branch (If Not Merged):
git branch -D branch_name
  1. Delete a Remote Branch:
git push origin --delete branch_name
  1. List both local & remote branches:
git branch -a
  1. Prunes (removes) local references to remote branches that no longer exist on the remote.
git fetch --prune
  1. Quickly Switch to the Previous Branch
git checkout -
  1. Show a Visual Branch Tree
git log --oneline --graph --all
  1. Search Commit Messages
git log --grep="bugfix"
  1. Configures Git to use Windows' built-in SSL/TLS (Schannel) instead of OpenSSL
git config --global https.sslBackend schannel
  1. Trigger the CI/CD pipeline with a blank commit
git commit --allow-empty -m 'Empty commit'
  1. Adding a Git subtree to your repository
git remote add -f eCommerceSolution.OrdersService https://github.com/mirajhad/eCommerceSolution.OrdersService.git
git subtree add --prefix=eCommerceSolution.OrdersService eCommerceSolution.OrdersService main --squash
  1. visualizing Git history
gitk