git 中查看commit歷史資訊

在 Git 中查看歷史 commit 資訊,以下是幾種常用方式,從基本到進階都有:


📜 基本方式:git log

git log

這會列出所有 commit 的詳細資訊,包括:

  • commit hash(版本 ID)
  • 作者
  • 日期
  • commit 訊息

🧼 精簡版:git log --oneline

git log --oneline

每筆 commit 只顯示簡短 hash 和訊息,非常適合快速瀏覽。


🧭 加上時間排序與作者:git log --pretty=format

git log --pretty=format:"%h - %an, %ar : %s"

這會顯示:

  • %h:簡短 hash
  • %an:作者名稱
  • %ar:相對時間(例如 3 days ago)
  • %s:commit 訊息

🔍 查看特定檔案的 commit 歷史

git log 檔案名稱

例如:

git log README.md

這樣可以追蹤某個檔案的修改歷程。


🧠 補充:查看某個 commit 的內容

git show commit_hash

例如:

git show a1b2c3d

會顯示該 commit 的差異(diff)、訊息、作者等。

Also See

File14FileLast Modified
git 中修改檔名且保留原來commit紀錄git 中修改檔名且保留原來commit紀錄1:24 AM - December 07, 2025
git Remote 常見情境與操作git Remote 常見情境與操作1:24 AM - December 07, 2025
git GUI tool, SourceTreegit GUI tool, SourceTree1:23 AM - December 07, 2025
把目前repo 所有的branch都push 到github把目前repo 所有的branch都push 到github8:20 PM - December 06, 2025
把目前 branch 上的修改(尚未 commit 的檔案)直接帶到一個新的 branch把目前 branch 上的修改(尚未 commit 的檔案)直接帶到一個新的 branch8:20 PM - December 06, 2025
從 Windows 把 repo 搬到 WSL再一次性 push 所有 branch 到GitHub 這樣就能避開 aux 檔名問題從 Windows 把 repo 搬到 WSL再一次性 push 所有 branch 到GitHub 這樣就能避開 aux 檔名問題8:20 PM - December 06, 2025
git指定初始化的 branch 名稱git指定初始化的 branch 名稱8:20 PM - December 06, 2025
git內部完全刪除一個檔案git內部完全刪除一個檔案8:20 PM - December 06, 2025
github上的repo clone下來check out 某一個dev branchgithub上的repo clone下來check out 某一個dev branch8:20 PM - December 06, 2025
github一台電腦同時使用兩個 GitHub 帳號github一台電腦同時使用兩個 GitHub 帳號8:20 PM - December 06, 2025
github actionsgithub actions8:20 PM - December 06, 2025
git 重新再從github上pull 所有branchgit 重新再從github上pull 所有branch8:20 PM - December 06, 2025
git 恢復到最近一次 git pull狀態,取消本地修改git 恢復到最近一次 git pull狀態,取消本地修改8:20 PM - December 06, 2025
git 初始化與推送流程圖git 初始化與推送流程圖8:20 PM - December 06, 2025