Skip to content

Troubleshooting Git

someone2639 edited this page Aug 9, 2022 · 1 revision

Troubleshooting Git

Here's where I'll go over some stuff you might run into while working with Git


Help, I want to revert a file!

If you're making frequent commits, this is no big deal! Just run:

git checkout path/to/file

and it'll be good as new.


I want to revert every file I changed back to a working commit!

If you're making frequent commits, this is no big deal! Just run:

git reset --hard

and your repo will be good as new. Just remember: any un-committed files will be lost.


I want to revert every file, except for one or two of them!

If you're making frequent commits, this is no big deal! Just use:

git stash path/to/file

on all files you want to keep, then run:

git reset --hard

After this, run this command until all your stashed files are back:

git stash pop

I accidentally merged a branch when I didn't want to! How do I go back?

If you're making frequent commits, this is no big deal! (Seeing a pattern here? This is just as important as saving a document, or your level's 3D model!) Just run:

git reset --hard HEAD~NUM

where NUM is the number of commits you want to revert.

If you want to record in the commit history that you've reverted a change, use

git revert HEAD~NUM

That's all I have for now! I'll update this post with both new troubleshooting queries and asciinema videos to show the effects of them!