使用git在文件的特定行上查找令牌的第一个介绍 [英] Using git to find first introduction of token on a specific line of a file
问题描述
使用git,有没有办法找出哪个修订引入了const标记?更具体地说,我想知道谁引入了令牌。
git blame显示谁对该行进行了最后一次更改,但我实际上希望查找第一次提交包含令牌。
git bisect 是你正在寻找的。使用这个命令,你可以很快找到提交什么提交const。
你用 git bisect start
开始这个过程,然后用git bisect good
标记一个没有const的旧版本,并将当前版本标记为 bisect bad
。然后系统会将您发送到中间的版本。你可以检查邪恶常量是否存在,并根据它来标记该版本的好坏。然后重复该过程,直到找到错误的提交。
Let's say I have a file A.cpp, and I notice an error on line 15 of the file. Let's say the error is a "const" on a function that returns a pointer to a member variable, meaning using const on the function is technically correct but semantically wrong. I would like to discuss the semantics with the author who made the change.
Using git, is there a way to find out which revision introduced the "const" token? More specifically, I'd like to know who introduced the token.
"git blame" shows who made the last change to the line, but I would actually like to find the first commit containing the token.
git bisect is what you are looking for. With this command you can find quickly what commit introduced the const.
You start the process with git bisect start
, then mark an old version without the const as good with git bisect good
and and the current one as bisect bad
. Then the system will send you to a version in the middle. You can check if the evil const is there, and mark that version good or bad depending on it. Then The process is repeated until you find the bad commit.
这篇关于使用git在文件的特定行上查找令牌的第一个介绍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!