(1)方法一 git log --pretty=oneline 文件名
例如:想搜索刚才的frameworks/base/packages/SystemUI/AndroidManifest.xml文件的提交记录,就可以使用命令:
oyp@buildServer3:~/E580$ git log --pretty=oneline frameworks/base/packages/SystemUI/AndroidManifest.xml 34b7ac981a39193ca78e0d4673ce66515c23988d [add a new feature to show the battery voltage value and level] 1.Support show the level of c1d6879f098775f1d703dfcfe814c4d726be47ad [Create MT6753-6M AP source repository]
如上所示,打印出来的就是针对文件frameworks/base/packages/SystemUI/AndroidManifest.xml文件的所有的改动历史,每一行最前面的那一长串数字就是每次提交形成的哈希值,接下来使用git show即可显示具体的某次的改动的修改。
下面就可以使用git show 命令查看具体的修改详情了。如:
git show <git提交版本号> <文件名>
git show 34b7ac981a39193ca78e0d4673ce66515c23988d frameworks/base/packages/SystemUI/AndroidManifest.xml
这样指定版本号,指定文件的就可以直接查看该文件的修改详情,不要看该版本号其他文件的修改。如下所示:
oyp@buildServer3:~/E580$ git show 34b7ac981a39193ca78e0d4673ce66515c23988d frameworks/base/packages/SystemUI/AndroidManifest.xml commit 34b7ac981a39193ca78e0d4673ce66515c23988d Author: oyp <oyp@runbo.net> Date: Mon Nov 30 19:47:48 2015 +0800 [add a new feature to show the battery voltage value and level] 1.Support show the level of battery voltage (0-5 levels). 2.Support show the battery voltage value (accurate to two decimal places). Appllicable Project: E580 Appllicable model: All Except IKE new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_0.png new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_1.png new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_2.png new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_3.png new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_4.png new file: frameworks/base/packages/SystemUI/res/drawable-hdpi/battery_voltage_5.png new file: frameworks/base/packages/SystemUI/src/com/android/systemui/MyBatteryService.java new file: frameworks/base/packages/SystemUI/src/com/android/systemui/MyBootCompletedReceiver.java modified: frameworks/base/packages/SystemUI/AndroidManifest.xml modified: frameworks/base/packages/SystemUI/res/layout/system_icons.xml modified: frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java modified: frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java modified: frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java diff --git a/frameworks/base/packages/SystemUI/AndroidManifest.xml b/frameworks/base/packages/SystemUI/AndroidManifest.xml old mode 100644 new mode 100755 index dfdc14c..5fb3545 --- a/frameworks/base/packages/SystemUI/AndroidManifest.xml +++ b/frameworks/base/packages/SystemUI/AndroidManifest.xml @@ -126,7 +126,11 @@ <!-- M: Add for data sim switch --> <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/> - + + <!-- added by ouyang start 2015-11-30 --> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <!-- added by ouyang end 2015-11-30 --> + <application android:name=".SystemUIApplication" android:persistent="true" @@ -407,5 +411,14 @@ <action android:name="android.intent.action.LOCALE_CHANGED" /> </intent-filter> </receiver> + + <!-- added by ouyang start 2015-11-30 --> + <receiver android:name=".MyBootCompletedReceiver" > + <intent-filter> + <action android:name="android.intent.action.BOOT_COMPLETED"/> + </intent-filter> + </receiver> + <service android:name=".MyBatteryService"/> + <!-- added by ouyang end 2015-11-30 --> </application> </manifest>
以上转载自:https://www.cnblogs.com/ouyangpeng/p/8537837.html
(2)方法二
很多时候,你只对某个特定文件的更改感兴趣。为了显示某个特定文件的历史,你只需要传入文件路径。比如说,下面这个命令返回所有和foo.py和bar.py文件相关的提交:
git log -- foo.py bar.py
需要注意,文件名的大小写。