Let's go fishing with git! 🎣
Background: I work on a team that supports a large, globally available video game. We are in the middle of implementing a set of features and there was a misunderstanding of where the data is to be saved in a database table for the user generated data service, but we have the exact code we are looking for in our git log.
I want to find the code that I wrote before so I don't have to think about how to do the task again because we spent that thought time already (Grug brain dev). my problem is I do not know the hash of what commit the code is in.
git log lets me see all of the logs, so that's usefulgrep -e 'pattern' helps search for text-p changes the output to the content of the commit| character takes output from command and pipes it into another commandgit log -p | grep -e 'FirstPublishedDate' will get me closer but the output is rather noisy; the
            word
            'FirstPublishedDate' is a common term in this development. Additionally, the output from grep
            is only
            structured by if a line contains that phrase; it's a bit of a salad without the context of git. so let's try
            again:
        
git log has -G to do a search, and I can narrow it by the branch namegit log -G'FirstPublishedDate' -p 143495-back-populate-new-filter-values will narrow the
                search to the
                branch and do the filtering by pattern for me, and then -p will show me the contentgrep -C 10 to show the ten lines around it, and use a new keyword like
                @@ to
                hone in on
                the hash.
            our answer is git log -G'FirstPublishedDate' -p 143495-back-populate-new-filter-values | grep -C 10 -e '@@'
           with the result
Right at the top. A not so unused function after all 🎣