Git: Accessing lost commits

Updated . Posted . Visible to the public.

Every time you amend, rebase or reset, git commits get "overwritten".

However, git still allows you to checkout those commits using their SHA1, given you can find it.

One option to do this is

git reflog
# or
git reflog show [BRANCH]

This will show a list of all commits the branch has recently pointed to.

Git might garbage collect those commits eventually, but this should only happen after several weeks.

Tobias Kraze
Last edit
Keywords
repair, dangling, undo
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2010-12-15 13:15)