最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What does `git bisect start` really do? - Stack Overflow

programmeradmin0浏览0评论

Please understand, I'm not asking how to use git bisect start. There is plenty documentation telling me to start a bisect session with a git bisect start command. What seems to be missing is any explanation of what doing this actually does.

To be clear, I know git bisect start has options that can be passed to it that do things. I'm only asking about what it does when you follow examples that pass nothing else.

My overriding question is about what state or mode git bisect start puts us in. Here are some other questions meant only to illustrate the nature of this one question:

  • What state actually changes because of the git bisect start command? Is there some query I could run that would tell me if we're in that state?
  • Why is this state necessary? Is it even needed?
  • What commands are not available while in this state? Which commands are only available when in it?
  • The git bisect ceremony seems to end with git bisect reset. Does that take us out of this state?
  • This tells me that rm -v .git/BISECT_* cleans up the files bisect creates. Are those files the only thing putting git in this bisect state?

All the documentation I'm finding just tells me to start bisect with git bisect start without telling me why.

Please understand, I'm not asking how to use git bisect start. There is plenty documentation telling me to start a bisect session with a git bisect start command. What seems to be missing is any explanation of what doing this actually does.

To be clear, I know git bisect start has options that can be passed to it that do things. I'm only asking about what it does when you follow examples that pass nothing else.

My overriding question is about what state or mode git bisect start puts us in. Here are some other questions meant only to illustrate the nature of this one question:

  • What state actually changes because of the git bisect start command? Is there some query I could run that would tell me if we're in that state?
  • Why is this state necessary? Is it even needed?
  • What commands are not available while in this state? Which commands are only available when in it?
  • The git bisect ceremony seems to end with git bisect reset. Does that take us out of this state?
  • This tells me that rm -v .git/BISECT_* cleans up the files bisect creates. Are those files the only thing putting git in this bisect state?

All the documentation I'm finding just tells me to start bisect with git bisect start without telling me why.

Share Improve this question edited Feb 6 at 15:37 candied_orange asked Feb 6 at 14:51 candied_orangecandied_orange 7,3342 gold badges30 silver badges65 bronze badges 12
  • 2 Why does it matter? What motivates the question? Implementation details that are not documented are subject to change. – Guildenstern Commented Feb 6 at 15:24
  • 3 "Why is this state necessary?" Because bisecting is a stateful operation. You have a known good commit and a known bad commit. When you say git bisect good or git bisect bad, you are updating one of those commits, but how does git know what the other one is? It has to remember it somewhere. Similarly, commands like git bisect log assume that git has been recording your earlier bisect decisions, so it has to remember them somewhere. – Raymond Chen Commented Feb 6 at 15:30
  • 1 @Guildenstern what motivates the question is a pathological need to know what I'm doing when I do things. I don't like working by rote. – candied_orange Commented Feb 6 at 15:40
  • 1 It is important to know how bisect works and how to use it. It is not important to know the internal implementation details, although maybe it makes you feel better. Just understand that the internal implementation details can and do change, so use it to build a mental model, not for the purpose of meddling with the implementation. The simple mental model is that git bisect is doing a binary search. You set the good (start) and bad (end), and git then asks you if a commit is good or bad, and your answer narrows the search. – Raymond Chen Commented Feb 6 at 16:38
  • 1 HEAD is not the important thing. That's just a courtesy that is unrelated to the job of bisecting. The important thing is that bisect remembers the "good" and "bad" commits and keeps picking commits that will help it find the commit at which things turn from good to bad. – Raymond Chen Commented Feb 6 at 21:16
 |  Show 7 more comments

1 Answer 1

Reset to default 4

git bisect start puts Git into bisect mode. It keeps track of this internally by creating the files

.git/BISECT_LOG
.git/BISECT_NAMES
.git/BISECT_START

During the course of bisecting, further scratch files can be created:

.git/BISECT_TERMS
.git/BISECT_ANCESTORS_OK

The presence of these files tells Git, or you, or git status, or an external tool, such as your terminal prompt, that you are in bisect mode, and gives meaning to any further git bisect commands you may care to give.

Indeed, you can in theory exit bisect mode, kaboom, with no other changes, just by deleting all those files. But it is more usual, and a much better idea, to have Git do that for you, by saying git bisect reset, which also by default returns you to the commit you were on when you started.

发布评论

评论列表(0)

  1. 暂无评论