version control - How to restore changes from commit in git? -


this question has answer here:

i know there tons of questions this, none solution worked out me. here happened:

i tried add new feature in app, created new branch implement feature.
after done merged master, deleted branch tested new feature , pushed changes repository (bitbucket btw).
code normal.

then needed add other feature tho.
created new branch again, tested other new feature in master, , let other branch "right" code.

the new feature didn't work, tried going other branch , merging master, delete changes made, gave me merge conflict tho, tried everything, wasn't able it.

i switched master , deleted branch right code.
wrong code in master.
hadn't pushed changes yet, commited, tried searching on how fix this, none worked.

i ran command: git checkout number of commit

i checked last pushed commit, had right code.

my project changed right code, , thought ok, thought restored changes.

i ran git status , output:

head detached @ f49fb28 changes not staged commit: (use "git add <file>..." update committed) (use "git checkout -- <file>..." discard changes in working directory)  modified:   .ds_store modified:   homework.xcworkspace/xcuserdata/henrique.xcuserdatad/userinterfacestate.xcuserstate  no changes added commit (use "git add" and/or "git commit -a") 

i ran git add -a along git commit -m "some message" , pushed repo thinking code there fixed. didn't tho, repo , project has same code, wrong code. possible checkout commit made right feature, not wrong 1 , code restores exact commit? if not, salvation redo everything.

please me!

edit: ran git status , output different now:

head detached f49fb28 changes not staged commit: (use "git add <file>..." update committed) (use "git checkout -- <file>..." discard changes in working directory)  modified:   homework.xcworkspace/xcuserdata/henrique.xcuserdatad/userinterfacestate.xcuserstate  no changes added commit (use "git add" and/or "git commit -a") 

is possible checkout commit made right feature

first of read attached full answer in comments.

to summary can use git reflog checkout desired commit.

here how reflog like:

enter image description here


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -