git rm --cached; git add; git status
Stop tracking a file. Cached option removes it from the git repo but keeps it in the working directory.
git revert --no-commit <hash>..HEAD
This walks back every commit from the HEAD until and not including <hash>. or you can do
git revert --no-commit HEAD~N..HEAD
git revert --quit
or do
git reset --soft HEAD~N
to just pop N commits
git checkout <branch>
git reset --hard <branch>
if you want to get rid of all your local changes on <branch>
git push/pull -u <repo_name> <branch_name>
e.g git pull -u origin prod to pull the origin/prod branch into this local branch that i’ve checked out
git config --local core.hooksPath .git/hooks
Full reset a repo back to it’s origin, removing untracked shit do
git reset --hard origin/main
git add forgotten-file.txt
git commit --amend --no-edit
--amend edits the commit at the tip. just –amend and -m would edit the message