(no title)
mbakke | 2 years ago
> searching for a function I deleted
git log -G someFunc
> quickly looking at a file on another branch to copy a line from itI use `git worktree` to "mount" long-running branches much to the same effect as Julias tool. To quickly look at a file from a non-mounted branch/commit, I use:
git show $REF:$FILENAME
> searching every branch for a function git log --all -G someFunc
Note that -G can be replaced with -F for a speedup if the pattern you are searching for is a fixed string.
masklinn|2 years ago
> git log -G someFunc
This will look for all changes mentioning someFunc throughout the history of the project.
Usually -S is more valuable, as it will look for changes in occurrence counts. So if you moved a call in a commit -G will flag it, but -S will ignore it (+1-1 = 0).
-S also defaults to fixed string, so no need for -F. Instead you need —pickaxe-regex to switch it to regex search.
globular-toast|2 years ago
It's kind of funny, I think, how most git users don't seem to know how to access any version other than the current one. So many people think of it simply as the annoying tool you have to use to make code changes but don't really know what version control is.
divbzero|2 years ago
I was inspired to look for something similar for the next best text editor (vim) and came across this: https://salferrarello.com/using-vim-view-git-commits/
Placing your cursor over a commit hash and entering K displays git show for that commit.masklinn|2 years ago
e.g. see something odd / interesting, activate blame view, and “show diff” / “annotate previous revision” to see how the hunk evolved. Often this provides fast-tracking through the file’s history as the hunk goes through inconsequential changes (e.g. reformatting, minor updates) without changing the gist of what sparked your interest.
cnity|2 years ago
tambourine_man|2 years ago
levidos|2 years ago