Skip to main content
deleted 3 characters in body
Source Link
Amir Shabani
  • 4.1k
  • 7
  • 33
  • 75

asAs far as iI know, --hard will discardsdiscard uncommitted changes. Since these aren't tracked by git. butBut you can undo the discarded commit.

$ git reflog

will listslist:

b0d059c HEAD@{0}: reset: moving to HEAD~1
4bac331 HEAD@{1}: commit: added level introduction....
....

where 4bac331 is the discarded commit.

Now just move the head to that commit::

$ git reset --hard 4bac331

as far as i know, --hard will discards uncommitted changes. Since these aren't tracked by git. but you can undo the discarded commit.

$ git reflog

will lists:

b0d059c HEAD@{0}: reset: moving to HEAD~1
4bac331 HEAD@{1}: commit: added level introduction....
....

where 4bac331 is the discarded commit.

Now just move the head to that commit::

$ git reset --hard 4bac331

As far as I know, --hard will discard uncommitted changes. Since these aren't tracked by git. But you can undo the discarded commit.

$ git reflog

will list:

b0d059c HEAD@{0}: reset: moving to HEAD~1
4bac331 HEAD@{1}: commit: added level introduction....
....

where 4bac331 is the discarded commit.

Now just move the head to that commit:

$ git reset --hard 4bac331
Source Link
suhailvs
  • 21.3k
  • 14
  • 102
  • 100

as far as i know, --hard will discards uncommitted changes. Since these aren't tracked by git. but you can undo the discarded commit.

$ git reflog

will lists:

b0d059c HEAD@{0}: reset: moving to HEAD~1
4bac331 HEAD@{1}: commit: added level introduction....
....

where 4bac331 is the discarded commit.

Now just move the head to that commit::

$ git reset --hard 4bac331