I know there are tons of questions like this, but none solution worked out for me. Here is what happened:
I tried to add a new feature in my app, so I created a new branch to implement this feature.
After I was done I merged it to master, deleted the branch that I tested the new feature and pushed the changes to the repository (bitbucket btw).
The code was normal.
Then I needed to add other feature tho.
I then created a new branch again, but now I tested this other new feature in master, and let the other branch with the "right" code.
The new feature didn't work, so I tried going to the other branch and merging it to master, to delete the changes I made, it gave me a merge conflict tho, I tried everything, but I just wasn't able to do it.
I than switched back to master and deleted the branch with the right code.
I was with the wrong code in master.
I hadn't pushed the changes yet, only commited, so I tried searching on how to fix this, none worked.
I then ran this command: git checkout NUMBER OF THE COMMIT
I checked the last pushed commit, which had the right code.
My project changed to the right code, and I thought everything was ok, I thought it restored the changes.
I ran git status
and that was the output:
HEAD detached at f49fb28
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .DS_Store
modified: Homework.xcworkspace/xcuserdata/Henrique.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit (use "git add" and/or "git commit -a")
I then ran git add -A
along with git commit -m "some message"
and pushed it to the repo thinking that the code would get there fixed. It didn't tho, now my repo AND project has the same code, the wrong code. Is it possible that I checkout the commit I made with the RIGHT feature, not the wrong one and my code restores to this exact commit? If not, my only salvation will be to redo everything.
PLEASE HELP ME!
EDIT: I RAN git status
AND THE OUTPUT WAS DIFFERENT NOW:
HEAD detached from f49fb28
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Homework.xcworkspace/xcuserdata/Henrique.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit (use "git add" and/or "git commit -a")