Debugging with git - PrismoSkills
Debugging with git
Use git blame to see when each line of the method was last edited and by whom.
Use -L option to limit the output to specified lines.
Example:
git blame -L 5,20 foo.txt
Binary search through commits.
Git provides a binary search command to help you find a misbehaving commit.
Suppose, there have been 16 commits in the last two days and a bug was introduced in one of these commits.
An obvious methodology to find the misbehaving commit is to use binary search.
A sample run for examining commits is as follows:
check 8th commit, PASS (bug not seen)
check 12th commit, FAIL (bug seen)
check 10th commit, PASS (bug not seen)
check 11th commit, PASS (bug not seen)
=> bug was introduced in the 12th commit
Manually, you would do this by calculating which commit to check out, then switching to that commit, checking test-status and so on.
With git, this can be automated using git bisect command.
Following commands show how the above can be made easy using git:
Read full article from Debugging with git - PrismoSkills
No comments:
Post a Comment