If your working tree looks like a junk drawer and you just want a fresh start without soul crushing regret later this guide will help. We will walk through checking the repo status resetting tracked files and removing untracked clutter while giving you safe escape hatches.
Run git status
to see modified tracked files and untracked files. This command shows what is about to be nuked. If any filenames look important take a breath and read them.
When you want to abandon local edits and return the working tree to the last commit use
git reset --hard HEAD
This forces the index and working tree to match HEAD and overwrites local changes. If that sounds terrifying and it should you have a couple of safer options.
git stash push -m "save"
so you can recover it later.git checkout -b temp-save
or git switch -c temp-save
.To delete files that are not tracked by Git use the clean command. Be warned this does not go to the recycle bin.
git clean -fd
To preview what will be deleted run a dry run first. This shows the targets without removing anything.
git clean -nd
If you also want to remove files that are ignored by .gitignore add the extra flag but only use it when you really mean it.
git clean -fdx
If you stashed changes restore them with git stash pop
or git stash apply
. If you committed to a temp branch you can merge or cherry pick the good bits back into your main branch.
git status
and actually read the file listgit clean -nd
to preview deletionsgit reset --hard HEAD
only when you are sureBottom line do not be cavalier. These commands are powerful and final by default. Use the dry run and stash tricks to make sure you do not accidentally delete something you will regret later.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.