I’m new to Git and I’ve made a huge mistake. Git kept prompting me with
git - rejected master -> master (non-fast-forward).
But, I still committed by using:
--force
This was disastrous, the whole project changed back to the stage it was at about a week ago. I’ve lost so many changes. I seem to have been pushed back to an earlier commit. Is there anyway I can get back to one of my newer commits? As I have made an enormous amount of changes and need to get them back.
Use
git reflogcommand. The reflog command will give you a good history of what’s been happening on the head of your branches. Run it, then find the line that refers to the state that you want to get back to.Once you found the commit, reset your branch to point to the specific commit.
The
--hardoptions sets the HEAD of the current branch back to the commit that you specify.