Reputation: 7677
Pulling my hair out here as I cannot seem to get this to work out.
I am aware that this is a duplicate of other questions that have been asked and answered however I am not sure if I am missing something here.
I was trying to push a commit to my repo, there was a large file and it came up with an error about it being over 100mb. So i removed the file and tried to commit again however it seemed that it still had the file in the committed changes so it failed again.
I then thought that running git reset --hard origin/master would clear the commits but it clears the changes that have been made. I've lost like a months work now and I am really not feeling great.
On the other questions, it suggests using git reset HEAD@{1} to revert the previous reset. I did this however when the reset completes, i do not have my files back, i did git status and it shows like
deleted: view/portal/reports/frequent-calls.view.php
deleted: view/portal/reports/not-contacts.view.php
modified: view/portal/reports/reports.view.php
modified: view/portal/reports/results.view.php
There the files marked as deleted are the ones that I want back. I am not sure if I am supposed to do something else now after this to get the files back. I would really appreciate any advice here!
Upvotes: 2
Views: 3417
Reputation: 1031
You pointed your repo to origin/master. To come back you have to do the same.
Your script is not working because you have to add the --hard
option too.
git reset --hard HEAD@{1}
However. If you are been doing more things since your first reset. It may not work now.
You should find your last commit with reflog command.
git reflog
You will see the latest positions of HEAD. Look for the previous one to the problematic reset. You can use the SHA1 or the position in the list.
git reset --hard SHA1
Or
git reset --hard HEAD@{theNumber}
Upvotes: 8