If you are worried about accidentally messing up your branch or if you are about to do something risky, you can always back it up by making a backup branch.
Command Line
git fetch --all
VS Code Source Control ... → Pull, Push → Fetch From All Remotes → origin/main
Command Line
git rev-list --count --first-parent <parent>..<branch_name>
VS Code Use the Git Graph VS Code extension to manually count the number of commits on your branch.
git reset --soft HEAD~<number of commits to squash>
This is to save the squash locally. Command Line
git add .
git commit -m "squashed commits into one"
VS Code
- Stage changes.
- Commit message.
- Push.
git push -f origin <name of branch>
Command Line
git rebase -i origin/dev
VS Code Source Control ... → Branch → Rebase Branch... → origin/dev
git push -f origin <name of branch>