In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how linux uses Tig to browse Git logs. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.
Tig is more than just a text interface for Git. Here's how it enhances your daily workflow.
If you use Git as your version control system, you may have convinced yourself that Git is a complex beast. It's a great tool, but browsing the Git repository can be troublesome. So tools like Tig have emerged.
From the Tig man page:
Tig is the ncurses-based text interface of git (1). It is primarily used as a Git repository browser, but it also helps to temporarily commit changes at the block level and acts as an output pager for various Git commands.
This basically means that Tig provides a text-based user interface that can be run in a terminal. Tig makes it easy for you to browse your Git log, but it can do much more than let you jump from the last submission to the previous one.
Tig screenshot
Many of the examples in this quick start Tig are taken directly from its excellent man pages. I strongly suggest you read it for more information.
Install Tig
Fedora and RHEL: sudo dnf install tig
Ubuntu and Debian: sudo apt install tig
MacOS:: brew install tig
For more information, see the official installation instructions.
Browse for submissions in the current branch
If you want to browse the latest submission in the branch, enter:
Tig
okay. This three-character command will launch a browser where you can browse the submissions in the current branch. You can think of it as a wrapper for git log.
To browse these outputs, you can use the up and down arrow keys to move from one submission to another. Pressing enter will split the window vertically, with the selected submission on the right. You can continue to browse up and down in the submission history on the left, and your changes will be displayed on the right. Use k and j to navigate up and down line by line, and the-and spacebar to turn the page up and down on the right. Use Q to exit the right pane.
Searching for tig output is also easy. Use / (forward) or? (backward) to search in the left and right panes.
Searching Tig
This is enough to allow you to browse your submission information. There are many key bindings here, but clicking h will display the help menu, where you can find its navigation and command options. Can you still use / and? To search the help menu. Use Q to exit the help.
Tig Help
Browse for changes to a single file
Because Tig is a wrapper for git log, it can easily accept the same parameters that can be passed to git log. For example, to browse the submission history of a single file, enter:
Tig README.md
Compare it with the output of the encapsulated Git command to see more clearly how Tig enhances the output.
Git log README.md
To include a patch in the original Git output, you can add the-p option:
Git log-p README.md
If you want to narrow the submission to a specific date range, try the following:
Tig-after= "2017-01-01"-- before= "2018-05-16"-- README.md
Once again, you can compare it with the original Git version:
Git log-- after= "2017-01-01"-- before= "2018-05-16"-- README.md browsing who changed the file
Sometimes you want to know who made changes to the file and why. Command:
Tig blame README.md
The device is essentially an encapsulation of git blame. As you might expect, it allows you to see who is the last person to edit the specified line, and it also allows you to see the submission that introduced the line. This is a bit like what vim's vim-fugitive plug-in provides: the Gblame command.
Browse your temporary storage area
If you are like me, you may have made a lot of changes in your temporary storage area. It's easy to forget them. You can view the latest items in the staging office in the following ways:
Git stash show-p stash@ {0}
You can find the second latest project in the following ways:
Git stash show-p stash@ {1}
and so on. If you call these commands when you need them, you will remember them more clearly than I do.
Like the Git command above, Tig can easily enhance your Git output with a simple call:
Tig stash
Try to execute this command in a warehouse that has temporary storage. You will be able to browse and search for your temporary items and quickly browse through your changes.
Browse your quotation
Git ref refers to the hash value of something you submit. This includes files and branches. Use the tig refs command to browse through all the ref and drill down into specific submissions.
Tig refs
When you are done, use Q to return to the previous menu.
Browse git status
If you want to see which files are temporarily saved and which are not tracked, use tig status, which is an encapsulation of git status.
Tig status
Browse git grep
You can use the grep command to search for expressions in a text file. The command tig grep allows you to browse the output of git grep. For example:
Tig grep-I foo lib/Bar
It allows you to browse the lib/Bar directory to search for foo output in a case-sensitive manner.
Output to Tig through standard input pipeline
If you want to pass the list of submitted ID to Tig, you must use the-- stdin flag so that tig show can read from standard input. Otherwise, tig show starts without input (a blank screen appears).
Git rev-list-- author=olaf HEAD | tig show-- stdin add a custom binding
You can customize Tig using the rc file. The following is an example of how to add some useful custom key bindings according to your preferences.
Create a file named .tigrc in the home directory. Open ~ / .tigrc in your favorite editor and add:
# apply selected staging content bind stash a!? git stash apply% (stash) # discard selected staging content bind stash x!? git stash drop% (stash)
As mentioned above, run tig stash to browse your temporary storage. However, with these bindings, you can press a to apply the item in staging to the warehouse, and press x to delete the item from the staging. Keep in mind that you can't execute these commands until you browse the temporary list. If you are browsing temporary items, please type Q to exit the view, and then press an or x to get the desired effect.
For more information, you can read about Tig key binding.
The above is all the contents of the article "how to use Tig to browse Git logs in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.