Key Points. The GitHub website will show a list of changes, and show the differences between commits. We can download or copy from old versions of files.
The git gc command cleans up unnecessary files and optimizes the local repository. GitHub runs this operation on its hosted repositories automatically on a regular basis based on a variety of triggers.
Currently, I don't believe it's possible to search within the complete history of a repository's code on the github website - the closest is just searching within the current code of a repository with the "code search" option on this page.
However, from the command line, you can find any commits that introduced or removed lines mentioning get_info
with the -S
option to git log
. e.g.:
git log -Sget_info -p
(n.b. there should be no space between -S
and the search term)
(also note: to search for more than one word, surround in '
):
git log -S'get info' -p
So, at a minimum that should find the commit where the function was first introduced and the one that removed it. I added the -p
so you can also see the patches - if lots of commits introduced changes that mentioned the function that may be helpful. If the function was only on another branch it might also be useful to use --all
to search all branches.
Jefromi points out in a comment below that git 1.7.4 will introduce the -G
option as an alternative - this change is summarized in a recent blog post from Junio Hamano (git maintainer): http://gitster.livejournal.com/48191.html
git log -G'your text' -p --all
Note the following from the docs;
[...] consider a commit with the following diff in the same file:
+ return frotz(nitfol, two->ptr, 1, 0); ... - hit = frotz(nitfol, mf2.ptr, 1, 0);
While git log
-G"frotz\(nitfol"
will show this commit, git log-S"frotz\(nitfol" --pickaxe-regex
will not (because the number of occurrences of that string did not change).
Kudos both Mark and Cascabel for pointing in the right direction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With