Using git is a long journey. I'm still learning things even after a decade of using it daily at work.
You will need time to understand what you do. Unfortunately, the best way to learn is to fail. And you will fail a lot with git, believe my own experience.
It requires understanding the concepts you are using: branch, rebase, merge, push, cherry-pick, stash, squash, fixup, reflog ā¦
You will need time to understand all these. The main issue is that the ones who make the most mistakes are the ones that are starting using git, and they are likely to do the worst mistakes. Yes, unfair.
I consider myself as an advanced git user. Some may say it's an imposter syndrome, because they think I'm almost an expert, but I consider we can always progress.
I would like to give you guys some references and tools.
Don't panic, and try to understand what you did
You need to figure what you made, before trying to fix it.
So take the time needed to understand.
Then you need to do a backup
As always, I would recommend you to perform backup before trying anything.
Copy your repository project, including the .git folder somewhere. Think about using mktemp -d.
Then try to solve your issue in this /tmp/ folder, not in your repository. This will avoid screwing everything even more. And you can restart trying fixing if you fail.
ugit/git-undo supports undoing the following operations, some are a WIP. If you know of any other operations that can be undone and are not in the list, make sure to raise an issue or make a quick PR šļø