240. git log 除錯指令
WHY
前陣子,RD同仁找來,說為什麼這樣的CI不會過。
查了一連串的LOG,發現是fast-forward的問題。
過程中用了一堆git 指令...
紀錄吧
Note
- 只顯示merge的log
git log --merges
- 顯示全部Log
git log
- 顯示單一提交的詳細訊息
git show <commit>
- 查詢某個特定提交的tag
git tag --points-at <commit>
- 列出所有tag及對應的commit值
git show-ref --tags
- 以圖形化顯示log
git log --graph
- 取得git的tag資料
# 取開頭第一個
git tag --points-at <commit> | head -1
# 取結尾第一個
git tag --points-at <commit> | tail -1
- Log Merge欄位的意思
假設顯示的資訊如下
commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t
Merge: 1a2b3c4 5d6e7f8
Author: John Doe <john.doe@example.com>
Date: Tue Sep 11 14:30:00 2024 +0800
Merge branch 'feature-branch' into 'develop'
develop的 commit值是 1a2b3c4
feature-branch的commit值是5d6e7f8
這兩個是 non-fast-forward合併,因為看得到Parents commit。
如果是Fast-Forward合併,只會顯示單個提交,不會有Merge
標記。
- pull時不使用rebase,而是使用merge
git pull --no-rebase