Amit Dhamu

Software Developer

Step Through Commits On A Branch In Git

Open a terminal window and do the following.

for commit in $(git rev-list <branch> --reverse)
do
    git checkout $commit
    read
done
Each time you press Enter, it will step through to the next commit on the <branch>. Have a second terminal window open to check stuff in the repository.

Credit

Alternatively, you can use git-bisect to pinpoint the commit where a problem might have started occurring. Assuming master is currently "bad":
➜ git checkout master
➜ git pull
➜ git bisect start
➜ git bisect bad
➜ git bisect good a8dbfe1 # last hash where the code was "good"
At this point, git will checkout revisions based on what you've told it and you can check each one. If it's good, simply put git bisect good and it will move to the next one and so on until you've found the culprit.


git / steps / debug / terminal / bisect

← Case Insensitive Multi Dimensional Array Sort Force Delete iCloud Account on macOS →

comments powered by Disqus