Lab 2

Hello everyone,

So I have been using Git for about 3 weeks now, and frankly, I still feel like I got a lot to learn in order to fully use Git’s potential. This week’s lab is to find some new Git’s command to work on, and I found out some interesting commands to learn and apply. This blog will introduce how to use git-grep and git-show.

1.git-grep

git-grep is used to print lines matching a pattern and easily search through anything. It will try to look through the files in the current working directory.

Examples:

Search working tree for text matching regular expression regexp:

git grep <regexp>

Search working tree for lines of text matching regular expression regexp1 or regexp2:

git grep -e <regexp1> [--or] -e <regexp2>

+Link

+git-grep doc link: https://git-scm.com/docs/git-grep

+git-grep references: https://stackoverflow.com/questions/2928584/how-to-grep-search-committed-code-in-the-git-history

2.git-show

It is used mainly to shows one or more objects (blobs, trees, tags and commits). This command can be useful when you want to search for some elements

Example:

Shows the tree pointed to by the tag v2.0.0

git show v2.0.0^{tree}


Shows the contents of the file Documentation/README as they were current in the 10th last commit of the branch next

git show next~10:Documentation/README

+Link

+git-grep doc link: https://git-scm.com/docs/git-show#git-show-codegitshowv100treecode

+git-grep references: https://stackoverflow.com/questions/51343765/what-does-git-show-do-all-by-itself

Overall, these commands can prove useful to me in the future for me. In the mean time, I will try to use these commands more to understand them properly. Thank you for reading.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s