3 ms·
How does this work in the face of unrelated refactoring? Say you first fix a bug somewhere, with a great commit comment. Then some refactoring happens, and the
by elygre 3y ago
How does this work in the face of unrelated refactoring? Say you first fix a bug somewhere, with a great commit comment. Then some refactoring happens, and the affected function is moved to a new class in a new file. Are you still able to track the original git comment?
- js2 3y agoSay you found the current commit through `git blame`. You run `git show` on that commit. The diff shows that the function you're interested in was actually moved so from the diff output you can see the previous filename and you have the function name. You could use: git log -GsomeRandomFunction -- path/to/some/random/source.ext That will then find the commit where `someRandomFunction` was removed from `source.ext` and then the commit before that where it was added to `someRandomFunction`. Git log has a gazillion options and I've probably used them all at one time or another, but 99% of the time, the only ones I need are `-G` and following a particular file. https://git-scm.com/docs/git-log#Documentation/git-log.txt--Gltregexgt https://git-scm.com/docs/git-log#Documentation/git-log.txt--... I also have `diff.renames` set to "copies" and `diff.algorithm` to "patience" in my `.gitconfig`: https://git-scm.com/docs/git-config#Documentation/git-config.txt-diffrenames https://git-scm.com/docs/git-config#Documentation/git-config... https://git-scm.com/docs/git-config#Documentation/git-config.txt-diffalgorithm https://git-scm.com/docs/git-config#Documentation/git-config...