4763b539-09b9-444b-9dd2-6262114164c3.avif
Imagine you've made a mistake in a commit and want to undo it without losing history. Instead of deleting the commit, git revert
creates a new commit that reverses the changes of the previous one. This way, your history stays intact while your files return to their previous state.
git reset
: Used before committing (removes staged changes).git revert
: Used after committing (creates a new commit that reverses previous changes).git log --oneline
.git revert <commit-id>
.Sometimes, your working directory has untracked files (files not added to Git). If you want to remove them without affecting tracked files, you can use git clean
.
git clean -n
→ Shows which files would be removed (dry run).git clean -f
→ Removes the untracked files permanently.⚠️ Be cautious when using git clean -f
, as it permanently deletes files!