Erdem Tuna
Erdem Tuna

Reputation: 604

Checkout to one of squashed commits

In a repository with squash-merge practice, can I go to the state of the repository in one of the squashed commits?

For the example below, I want to find commit m1 by checking out commit r1.

m1 - m2 ------- m3   <- master (r1, r2, and r3 are squashed into m3)
  \            
   r1 - r2 - r3  <- deleted branch

Upvotes: 2

Views: 667

Answers (2)

You can use git reflog --all. It lists all recent actions and related commit hashes. If you find the commit there, you can git checkout <commit_hash>.

Note: --all option is for listing reflogs of all references, not just the HEAD.

Upvotes: 1

Anas Altarazi
Anas Altarazi

Reputation: 117

in git when you squash commits actually you are deleting them from the history, so, you don't have any chance to rollback (as I know) but try the following command :

git log

if you find your commit you can open it in temp branch by using this command :

git checkout COMMIT_HASH

Upvotes: -2

Related Questions