DEV Community

Takuya Kikuchi
Takuya Kikuchi

Posted on

Debug: finding at which commit a 🐞 is created

When you found a bug and want to identify which commit you produced the bug, you can check out commit and check 👍

Check commit ids

$ git log --graph --decorate --pretty=oneline --abbrev-commit

Creating an alias if you like 😉
Git - Git Aliases

Image 2021-09-29 at 7.27.01 PM

Checkout commit and check

$ git checkout {commit id}

Go back to the latest commit

git checkout {branch name}

Note

Having a nice commit message helps spot the respective commits 😉

Discussion (2)

Collapse
bonnev profile image
Bonnev

Check also

git bisect

it automatically and efficiently checks out commits using binary search to find the bug: riptutorial.com/git/example/2670/b....

Collapse
takuyakikuchi profile image
Takuya Kikuchi Author

@bonnev Thanks a lot for sharing git bisect! This is TIL for me ✨