Friday, August 28, 2015

TIP: language-aware Git gives you contextual searches

TIP: if Git is setup correctly, Git knows we're working with Python, so commands are clearer.

setup: echo '*.py filter=python' >> .gitattributes

Example: find the usage/definition of formatted_tax:

$ git grep -p formatted_tax

app/models.py=2083=class Order(CreatedMixin):
app/models.py:2454:            'tax': self.formatted_tax,

The second line says the symbol was found on line 2454.  The first line shows the context, the symbol was found inside the class Order! Very useful

related: 'git grep' and Language-Aware Diffs

No comments:

Post a Comment