Git logThe advantage of a version control system is that it records changes. These records allow us to retrieve the data like commits, figuring out bugs, updates. But, all of this history will be useless if we cannot navigate it. At this point, we need the git log command. Git log is a utility tool to review and read a history of everything that happens to a repository. Multiple options can be used with a git log to make history more specific. Generally, the git log is a record of commits. A git log contains the following data:
How to Exit the git log Command?There may be a situation that occurs, you run the git log command, and you stuck there. You want to type or back to bash, but you can't. When you click the Enter key, it will navigate you to the older command until the end flag. The solution to this problem is to press the q (Q for quit). It will quit you from the situation and back you to the command line. Now, you can perform any of the commands. Basic Git logGit log command is one of the most usual commands of git. It is the most useful command for Git. Every time you need to check the history, you have to use the git log command. The basic git log command will display the most recent commits and the status of the head. It will use as: The above command will display the last commits. Consider the below output: ![]() The above command is listing all the recent commits. Each commit contains some unique sha-id, which is generated by the SHA algorithm. It also includes the date, time, author, and some additional details. We can perform some action like scrolling, jumping, move, and quit on the command line. To scroll on the command line press k for moving up, j for moving down, the spacebar for scrolling down by a full page to scroll up by a page and q to quit from the command line. <Git Log OnelineThe oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message. It will be used as follows: So, usually we can say that the --oneline flag causes git log to display:
Consider the below output: ![]() As we can see more precisely from the above output, every commit is given only in one line with a seven-digit sha number and commit message. Git Log StatThe log command displays the files that have been modified. It also shows the number of lines and a summary line of the total records that have been updated. Generally, we can say that the stat option is used to display
It will be used as follows: The above command will display the files that have been modified. Consider the below output: ![]() From the above output, we can see that all listed commits are modifications in the repository. Git log P or PatchThe git log patch command displays the files that have been modified. It also shows the location of the added, removed, and updated lines. It will be used as: Or Generally, we can say that the --patch flag is used to display:
Consider the below output: ![]() The above output is displaying the modified files with the location of lines that have been added or removed. Git Log GraphGit log command allows viewing your git log as a graph. To list the commits in the form of a graph, run the git log command with --graph option. It will run as follows: To make the output more specific, you can combine this command with --oneline option. It will operate as follows: Filtering the Commit HistoryWe can filter the output according to our needs. It's a unique feature of Git. We can apply many filters like amount, date, author, and more on output. Each filter has its specifications. They can be used for implementing some navigation operations on output. Let's understand each of these filters in detail. By Amount: We can limit the number of output commit by using git log command. It is the most specific command. This command will remove the complexity if you are interested in fewer commits. To limit the git log's output, including the - ![]() As we can see from the above output, we can limit the output of git log. By Date and Time: We can filter the output by date and time. We have to pass --after or -before argument to specify the date. These both argument accept a variety of date formats. It will run as follows: The above command will display all the commits made after the given date. Consider the below output: ![]() The above command is listing all the commits after "2019-11-01". We can also pass the applicable reference statement like "yesterday," "1 week ago", "21 days ago," and more. It will run as: The above command will display the commits which have been made 21 days ago. Consider the below output: ![]() We can also track the commits between two dates. To track the commits that were created between two dates, pass a statement reference --before and --after the date. Suppose, we want to track the commits between "2019-11-01" and "2019-11-08". We will run the command as follows: The above command will display the commits made between the dates. Consider the below output: ![]() The above output is displaying the commits between the given period. We can use --since and --until instead of --after and --before. Because they are synonyms, respectively. By Author: We can filter the commits by a particular user. Suppose, we want to list the commits only made by a particular team member. We can use -author flag to filter the commits by author name. This command takes a regular expression and returns the list of commits made by authors that match that pattern. You can use the exact name instead of the pattern. This command will run as follows: The above command will display all the commits made by the given author. Consider the below output: ![]() From the above output, we can see that all the commits by the author ImDwivedi1 are listed. We can use a string instead of a regular expression or exact name. Consider the below statement: The above statement will display all commits whose author includes the name, Stephen. The author's name doesn't need to be an exact match; it just has the specified phrase. As we know, the author's email is also involved with the author's name, so that we can use the author's email as the pattern or exact search. Suppose, we want to track the commits by the authors whose email service is google. To do so, we can use wild cards as "@gmail.com." Consider the below statement: The above command will display the commits by authors as given in the pattern. Consider the below output: ![]() By Commit message: To filter the commits by the commit message. We can use the grep option, and it will work as the author option. It will run as follows: We can use the short form of commit message instead of a complete message. Consider the below output. ![]() The above output is displaying all the commits that contain the word commit in its commit message. There are many other filtering options available like we can filter by file name, content, and more. Next TopicGit Diff
|
Python tutorial provides basic and advanced concepts of Python.
Vue.js is an open-source progressive JavaScript framework
HTML refers to Hypertext Markup Language. HTML is the gateway ...
Java is an object-oriented, class-based computer-programming language.
PHP is an open-source,interpreted scripting language.
Spring is a lightweight framework.Spring framework makes ...
JavaScript is an scripting language which is lightweight and cross-platform.
CSS refers to Cascading Style Sheets...
jQuery is a small and lightweight JavaScript library. jQuery ...
SQL is used to perform operations on the records stored in the database.
C programming is considered as the base for other programming languages.
JavaScript is an scripting language which is lightweight and cross-platform.
Vue.js is an open-source progressive JavaScript framework
ReactJS is a declarative, efficient, and flexible JavaScript library.
jQuery is a small and lightweight JavaScript library. jQuery ...
Node.js is a cross-platform environment and library for running JavaScript app...
TypeScript is a strongly typed superset of JavaScript which compiles to plain JavaScript.
Angular JS is an open source JavaScript framework by Google to build web app...
JSON is lightweight data-interchange format.
AJAX is an acronym for Asynchronous JavaScript and XML.
ES6 or ECMAScript 6 is a scripting language specification ...
Angular 7 is completely based on components.
jQuery UI is a set of user interface interactions built on jQuery...
Python tutorial provides basic and advanced concepts of Python.
Java is an object-oriented, class-based computer-programming language.
Node.js is a cross-platform environment and library for running JavaScript app...
PHP is an open-source,interpreted scripting language.
Go is a programming language which is developed by Google...
C programming is considered as the base for other programming languages.
C++ is an object-oriented programming language. It is an extension to C programming.
C# is a programming language of .Net Framework.
Ruby is an open-source and fully object-oriented programming language.
JSP technology is used to create web application just like Servlet technology.
The JSTL represents a set of tags to simplify the JSP development.
ASP.NET is a web framework designed and developed by Microsoft.
Perl is a cross-platform environment and library for running JavaScript...
Scala is an object-oriented and functional programming language.
VBA stands for Visual Basic for Applications.
Spring is a lightweight framework.Spring framework makes ...
Spring Boot is a Spring module that provides the RAD feature...
Django is a Web Application Framework which is used to develop web applications.
Servlet technology is robust and scalable because of java language.
The Struts 2 framework is used to develop MVC based web applications.
Hibernate is an open source, lightweight, ORM tool.
Solr is a scalable, ready-to-deploy enterprise search engine.
SQL is used to perform operations on the records stored in the database.
MySQL is a relational database management system based...
Oracle is a relational database management system.
SQL Server is software developed by Microsoft.
PostgreSQL is an ORDBMS.
DB2 is a database server developed by IBM.
Redis is a No SQL database which works on the concept of key-value pair.
SQLite is embedded relational database management system.
MongoDB is a No SQL database. It is an document-oriented database...
Memcached is a free, distributed memory object caching system.
Hibernate is an open source, lightweight, ORM tool.
PL/SQL is a block structured language that can have multiple blocks in it.
DBMS Tutorial is software that is used to manage the database.
Spark is a unified analytics engine for large-scale data processing...
IntelliJ IDEA is an IDE for Java Developers which is developed by...
Git is a modern and widely used distributed version control system in the world.
GitHub is an immense platform for code hosting.
SVN is an open-source centralized version control system.
Maven is a powerful project management tool that is based on POM.
Jsoup is a java html parser.
UML is a general-purpose, graphical modeling language.
RESTful Web Services are REST Architecture based Web Services.
Postman is one testing tools which is used for API testing.
JMeter is to analyze the performance of web application.
Jenkins builds and tests our software projects.
SEO stands for Search Engine Optimization.
MATLAB is a software package for mathematical computation, visualization...
Unity is an engine for creating games on multiple platforms.
Hadoop is an open source framework.
Pig is a high-level data flow platform for executing Map Reduce programs of Hadoop.
Spark is a unified analytics engine for large-scale data processing...
Spring Cloud is a framework for building robust cloud applications.
Spring Boot is a Spring module that provides the RAD feature...
AI is one of the fascinating and universal fields of Computer.
Cloud computing is a virtualization-based technology.
AWS stands for Amazon Web Services which uses distributed IT...
Microsoft Azure is a cloud computing platform...
IoT stands for Internet of Things...
Spring Cloud is a framework for building robust cloud applications.
Email:jjw.quan@gmail.com