Writing these down because I keep forgetting them.
Situation 1 - Local commit wrong branch
Made a commit to a branch I shouldn't have locally i.e.
main should be in
git reset --hard HEAD^
Resets the branch to the commit specified and remove changes (
--hard ) commit in question is current - 1
~X where X is the amount of commits to backtrack example
HEAD~2 to move back last 2 commits
Situation 2 - There are untracked files in that branch now
Say you reset the commit and it still shows some files as uncommitted and untracked now. Now clean up the extra directories and files
git clean -fd
Clean up the current branch by force deleting all untracked directories and files