Beyond “Commit” and “Push”: 5 Advanced Git Features You Should Know


Page 2

{Git Bisect is a powerful debugging tool that helps you pinpoint the exact commit that introduced a bug in your project. This feature is a great example of how Git can be much more than just a version control system, offering valuable debugging capabilities as well!}

Git bisect is a tool to find a commit that causes a bug.

Page 2

{First, you need to inform Git of a commit where the code is working correctly \(the "good" commit\) and another commit where the bug is present \(the "bad" commit\).}

First, we have to set a good commit and a bad commit. These will be the start and end points of a binary search.

Page 2

{Git then selects a commit that lies halfway between the two points you provided and prompts you to confirm whether the bug is present in that commit.}

Git then finds a commit halfway through, and we have to test if the commit works.

Page 2

{This iterative process continues as Git narrows down the range of commits until it pinpoints the exact commit that introduced the bug.}

Then, repeat the process, which means, after a while, it will find the buggy commit halfway somewhere.

So, it uses binary search to find the commit causing the bug.

Page 3

{\$ git bisect start \$ git bisect bad \# Current version is "bad" \$ git bisect good \<good-commit-hash\> \# Commit that is known to be "good" \# Git then checks out a commit for you to test and you mark it as "good" or "bad" \$ git bisect good \# or git bisect bad, depending on your conclusion \# Repeat until Git identifies the problematic commit \$ git bisect reset \# to end the bisect session}

Here’s how we can start a git bisect session.

Page 3

{allows Git to remember how you've resolved a merge conflict so that it can automatically resolve it the same way if it encounters the same conflict again.}

Git Rerere is a way to tell Git to remember the merge conflict I already solved and reuse it again.

Page 3

{This is particularly useful when working with long-lived topic branches, as you may encounter the same conflicts repeatedly.}

There are long-living branches that always need to resolve the same conflict, so this can help in those cases.

Page 4

{git config --global rerere.enabled true}

How to enable Rerere.

Page 4

{Once enabled, Git will automatically record how you resolve conflicts and reuse these resolutions in future conflicts.}

I wonder if this will cause problems because I feel it makes me trust blindly in Git for conflict resolution.

#Drafting #Literature #Development