How to use Git

Need to go back to a previous version with everything else exactly as it was at that moment?

  1. Switch to your main branch (just to be sure)

    git checkout master

    (or: git checkout main - use whichever name your main branch has)

  2. Move the branch exactly to the desired commit + delete everything newer + discard all changes

    git reset --hard <commit-id>

  3. Remove all untracked files and directories (newly created files/folders)

    git clean -fd