Log dan History

Melihat Hasil Pekerjaan Masa Lalu

Teknik Kolaborasi TI

Persiapan


Sejarah Kode


Contoh Penggunaan Git Log

$ git log
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author: Jason Chen <[email protected]>
Date:   Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
commit b5256f7982a60b5359e49fc328fcce7603f85070
Author: Jason Chen <[email protected]>
Date:   Thu May 8 09:00:04 2014 -0700

 Update instructions
 
commit a6e1e9768ac8c4a8e24d0652460e9f9f25f81af8
Author: Jason Chen <[email protected]>
Date:   Thu May 8 08:49:31 2014 -0700

 remove warning
...

Melihat Sebanyak n Commit yang Lalu Saja

$ git log -n

dengan n adalah jumlah log yang ingin dilihat

Contoh

$ git log -2
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author: Jason Chen <[email protected]>
Date:   Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
commit b5256f7982a60b5359e49fc328fcce7603f85070
Author: Jason Chen <[email protected]>
Date:   Thu May 8 09:00:04 2014 -0700

 Update instructions
...

Kombinasi Perintah Flag

Semua flag yang ada bisa dikombinasikan. Contoh: melihat perbedaan antar commit dari 2 commit terakhir:

$ git log -2 -p

(urutan tidak penting)

Melihat Perbedaan yang Ada Antar Commit

$ git log -p
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author: Jason Chen <[email protected]>
Date:   Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
diff --git a/test/karma.js b/test/karma.js
index e722991..a2259c8 100644
--- a/test/karma.js
+++ b/test/karma.js
@@ -87,7 +87,7 @@ module.exports = function(config) {
 if (process.env.TRAVIS) {
  config.transports = ['xhr-polling'];
  config.sauceLabs.build = 'travis-' + process.env.TRAVIS_BUILD_ID;
-    if (process.env.TRAVIS_BRANCH == 'master') {
+    if (process.env.TRAVIS_BRANCH == 'master' && !process.env.TRAVIS_PULL_REQUE
  config.sauceLabs.username = 'quill-master';
  config.sauceLabs.accessKey = '685c8996-7b70-4543-8167-58f8e88a8484';
}
...

Perbedaan Antar Commit


Perbedaan Antar Kata dalam Commit

$ git log -p --word-diff
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author: Jason Chen <[email protected]>
Date:   Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
diff --git a/test/karma.js b/test/karma.js
index e722991..a2259c8 100644
--- a/test/karma.js
+++ b/test/karma.js
@@ -87,7 +87,7 @@ module.exports = function(config) {
 if (process.env.TRAVIS) {
 config.transports = ['xhr-polling'];
 config.sauceLabs.build = 'travis-' + process.env.TRAVIS_BUILD_ID;
 if (process.env.TRAVIS_BRANCH == [-'master')-]{+'master' && !process.env.TRA
  config.sauceLabs.username = 'quill-master';
  config.sauceLabs.accessKey = '685c8996-7b70-4543-8167-58f8e88a8484';
 }
...

Perbedaan Antar Kata dalam Commit


Statistik Commit


Statsitik Commit

$ git log --stat
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author: Jason Chen <[email protected]>
Date:   Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
test/karma.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
...

Mengganti Tampilan Commit


Mengganti Tampilan Commit

$ git log --pretty=oneline
7dab74f3ff21dcbb107c8be34db1253eaca41ca1 use standard account for pull requests
b5256f7982a60b5359e49fc328fcce7603f85070 Update instructions
a6e1e9768ac8c4a8e24d0652460e9f9f25f81af8 remove warning
75c8f63eba4924c5545df89e4e82edaa6be97bd6 Merge branch 'develop'
7659d6dcc7d28c67b06efb59d5c5767a9880d624 bump version
b08fcbaa63b8e30989de1659710042eb9a9cc5fb fix multicursor placement on first char
...

Mengganti Tampilan Commit

$ git log --pretty=fuller
commit 7dab74f3ff21dcbb107c8be34db1253eaca41ca1
Author:     Jason Chen <[email protected]>
AuthorDate: Thu May 8 22:31:46 2014 -0700
Commit:     Jason Chen <[email protected]>
CommitDate: Thu May 8 22:31:46 2014 -0700

 use standard account for pull requests
 
...

Mengganti Tampilan Commit (--pretty=format)

$ git log --pretty=format:"%h - %an (%ar): %s"
7dab74f - Jason Chen (4 days ago): use standard account for pull requests
b5256f7 - Jason Chen (5 days ago): Update instructions
a6e1e97 - Jason Chen (5 days ago): remove warning
75c8f63 - Jason Chen (5 days ago): Merge branch 'develop'
7659d6d - Jason Chen (5 days ago): bump version
...

Mengganti Tampilan Commit (--pretty=format)

Menampilkan Grafik Commit (terutama untuk percabangan)

$ git log --pretty=format:"%h - %s" --graph
* 7dab74f - use standard account for pull requests
* b5256f7 - Update instructions
* a6e1e97 - remove warning
*   75c8f63 - Merge branch 'develop'
|\
| * 7659d6d - bump version
| * b08fcba - fix multicursor placement on first character of right align text
| * 5e60376 - fix tests
| * e5259e0 - tweak styles
| * ce598e1 - fix styles for align in snow
...

Filter Keluaran Commit


Filter Berdasarkan Waktu

$ git log --until="2014-04-30" -2
commit 5f0384a5834a5e0b42e8b0fce4ca2c3e8741681d
Author: Jason Chen <[email protected]>
Date:   Tue Apr 29 23:40:32 2014 -0700

 fix image insertion
 
commit 38e8b2b2edb1c3d29ec2300c70ec1281f33fffc5
Author: Jason Chen <[email protected]>
Date:   Tue Apr 29 23:12:23 2014 -0700

 implement image tooltip
 

Filter Berdasarkan Nama

$ git log --format="%h - %s" --committer=byronm -3
9fb830d - Add messages to failed tests in undo/redo suite.
e207715 - Bump selenium-webdriver to handle Firefox 24.
d033324 - Use rgb for consistency.

Filter Berdasarkan Kata Kunci

$ git log --format="%h - %s" --grep="Firefox"
e207715 - Bump selenium-webdriver to handle Firefox 24.
418e0d5 - Test deleting newline and then inserting.
791b56d - Remove hyperlink from insert tests.
4174d98 - Added another cursor test.
61b4dfe - Focus the editor in webdriver initialization.
cb6ddec - Explicitly turn on native events for Firefox.
d3ffeec - ownerDocument is null if element is document in Firefox
524e06a - Added hack to prevent Firefox from adding undesired newlines.