3 ms·
I strongly agree. Git isn't only code sharing that you commit and forget. It is a database of code that tracks what changed, why changed, who changed and when
by lucasoshiro 2y ago
I strongly agree.
Git isn't only code sharing that you commit and forget. It is a database of code that tracks what changed, why changed, who changed and when changed.
Want to know why a piece of code exists? Find the commit that introduced it, read the message. If it's not enough, you can search the commit and find the discussion on GitHub/GitLab/etc.
A new bug suddenly appeared? Use git bisect to find what was the commit that introduced it.
Some months ago I posted some tips about using Git as a debugging tool, if you want to read more about it: https://news.ycombinator.com/item?id=39877637 https://news.ycombinator.com/item?id=39877637
- PaulDavisThe1st 2y agoSee also: git log -L:funcname:file funcname will be matched after wrapping it in a "function declaration identifying" regexp. Get the entire history of a given function (as long as it was in <file>). Not a daily driver, but sometimes unimaginably valuable.
- ufo 2y agoCould you please give a concrete example of how to use funcname? I tried looking in the man page and didn't get it.
- deleted 2y ago[deleted]
- PaulDavisThe1st 2y agoI work in C++, so I might be looking for the history of Session::set_state (XMLNode const & node) I would write: git log -L:set_state:session_state.cc If I worked in C, and I had this in a file: void some_function_name (type1_t t1, type2_t t2) I would write git log -L:some_function_name:thefile.cc
- lucasoshiro 2y agoThanks! I'll check it and I'll update my article with that!