DEV Community

Cover image for What's happens when you `git commit`

What's happens when you `git commit`

Maxence Poutord on October 16, 2019

Nowadays, most of our project use Git as a version control system. It means most of our project have a .git folder. But, have you ever tried to ope...
Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

Is there a way to tell, from the git reflog view, that the third commit is orphaned?

Collapse
 
evolutionxbox profile image
Jonathan Cousins

I think there is a way. The term is “an unreachable” commit. I don’t know the commands though.

Collapse
 
maxpou profile image
Maxence Poutord • Edited

I don't think you can do it with reflog.
However, you can use git fsck --lost-found. This command will give you all dangling blobs and commits.
After the command, check the .git/lost-found folder.

In a "hello world" project with a few commits it can be cool... however on a big project it will give you hundred of files 😕

👉git-scm.com/docs/git-fsck

Collapse
 
torianne02 profile image
Tori Crawford

You have successfully sparked my interest in learning the ins-and-outs of Git. Great post!!

Collapse
 
maxpou profile image
Maxence Poutord

Thanks Victoria! I'm glad if my article raised your interest in Git 😃

Collapse
 
leewynne profile image
Lee

Very informative! Thanks!

Collapse
 
maxpou profile image
Maxence Poutord

thank for your feedback Lee :)

Collapse
 
jukmr profile image
Julian Mérida

Excelent post! I completely forgot that reflog existed so it is very useful to remember it again! Thank you!

Collapse
 
maxpou profile image
Maxence Poutord

Thank you! And yeah git reflog saved my life a couple of times :D

Collapse
 
denojike profile image
denojike

Informative. Thank you

Collapse
 
strahlistvan profile image
Stráhl István

Great post! I just never opened the .git folder so far.