- Continuous Integration,Delivery,and Deployment
- Sander Rossel
- 405字
- 2021-07-02 15:42:17
Reviewing commits
No doubt, you sometimes need to review some commits or those of others. One thing you can do is look them up in GitLab or whatever Git server you use. You can also view them in Git GUI or any Git client. However, it is also possible to look them up using the command line. The git log command lists all commits in your current branch. There are some caveats though. Since the list of commits can be very long, they will never fit in your console window. What Git does to make this manageable is page the results. You can use the Enter key to show new lines. When you want to exit the log, you have to type q (Linux style). Usually in Windows, you exit such operations using Ctrl + C, but this will not exit the log and will probably mess up your command window and leave you confused and annoyed, and ultimately make you hit the X button and restart your console:
git log
commit f90cfa90227bf1cb21d8023b03273c991fc2f471
Author: Sander Rossel <sander.rossel@gmail.com>
Date: Sun Jan 29 21:40:16 2017 +0100
Added xlsx support.
commit 475bb165299b3d85c142b03462be9f82b8fbefb1
Author: Sander Rossel <sander.rossel@gmail.com>
Date: Sun Jan 29 21:38:16 2017 +0100
Added reporting module.
commit 51eadeab96e1950f5e61273fcb3bbfb24a75e901
Author: Sander Rossel <sander.rossel@gmail.com>
Date: Sun Jan 29 21:37:07 2017 +0100
Added reporting files.
[...]
:q
[Alternatively]
(END)q
As you can see, the latest commits are at the top as those are the ones you most likely want to see. There are a couple of useful switches to log that can be very useful. The --pretty=oneline or --oneline switches are probably the ones you would use the most. It simply prints every commit on a single line, giving you a much clearer overview of the various commits. The only difference between the two is that --pretty=oneline prints the full commit hash whereas --online prints the short version. Other --pretty formats are short, full, and fuller, but you will need to use the full --pretty=[format] syntax for those. The -p switch lists all the differences in the commit. It is also possible to limit the number of results using -[some number], for example -2:
git log --oneline -p -2
Other useful switches that can help you sort the results are --skip, --since, --after, --until, --before, and --author. There are dozens of switches for log, so if you really need this kind of functionality, I suggest you look it up in the Git documentation.
- DB2 V9權威指南
- 精通Nginx(第2版)
- Java應用與實戰
- The Modern C++ Challenge
- PyTorch Artificial Intelligence Fundamentals
- R語言數據可視化實戰
- Mastering Rust
- 精通Linux(第2版)
- Hands-On Kubernetes on Windows
- RubyMotion iOS Develoment Essentials
- Java 從入門到項目實踐(超值版)
- Tkinter GUI Programming by Example
- Windows 10 for Enterprise Administrators
- jQuery Essentials
- PHP高性能開發:基礎、框架與項目實戰