- 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.
- OpenDaylight Cookbook
- Mastering JavaScript Object-Oriented Programming
- Android開(kāi)發(fā)精要
- 小創(chuàng)客玩轉(zhuǎn)圖形化編程
- Mastering SVG
- 劍指Offer(專項(xiàng)突破版):數(shù)據(jù)結(jié)構(gòu)與算法名企面試題精講
- WSO2 Developer’s Guide
- Python Network Programming Cookbook(Second Edition)
- R Deep Learning Cookbook
- 網(wǎng)站構(gòu)建技術(shù)
- Node.js Design Patterns
- HTML5秘籍(第2版)
- 小程序,巧應(yīng)用:微信小程序開(kāi)發(fā)實(shí)戰(zhàn)(第2版)
- 移動(dòng)互聯(lián)網(wǎng)軟件開(kāi)發(fā)實(shí)驗(yàn)指導(dǎo)
- AutoCAD 2009實(shí)訓(xùn)指導(dǎo)