Tag: git

  • 全面竄改 git commit 歷史記錄

    全面竄改 git commit 歷史記錄

    最近遇到一個問題:「GitHub 上的 commit 記錄可以證明一定是某人 commit 的嗎?」。 這個問題的答案是:「NO」。 git commit 不似區塊鏈有能力做出無法偽造的記錄,透過不同的方式,我們可以全面的竄改 git commit 的歷史記錄,不論是作者、上傳者或是時間都有辦法可以修改,以下將一一介紹如何操作。 0. 前置作業 首先先在本機建立一個空的 git repo,接著隨意寫入空的檔案: $ mkdir git-test $ cd git-test $ git init $ touch README.md $ git add README.md 1. 基本 Git 設定 – 設定識別資料 根據 git 官方的資料,第一次使用 Git 必須要設定識別資料,而且識別資料會影響到提交的結果:「每次Git提交會使用這些資訊,而且提交後不能再被修改」 $ git config –global user.name “John Doe” $ git config…

  • 如何寫一個 Git Commit Message

    如何寫一個 Git Commit Message

    原標題:How to Write a Git Commit Message, 31 Aug 2014, By Chris Beams 英文原文:https://chris.beams.io/posts/git-commit/,中文翻譯經作者 Chris Beams 同意。中文翻譯經 Yung-Ching Hsiao 協助潤飾、修正。 導論 | Git 7 條規則 | 小技巧 導論:為什麼好的 commit message 很重要 如果你隨機挑一個 git repo 的 log 來閱讀,你大概會發現它的 commit message 是一團糟。舉個例子,看看這些我以前 committing 到 Spring 的 gems: $ git log –oneline -5 –author cbeams –before “Fri Mar…

  • delete git branch local and remote (刪除本地跟遠端 git branch)

    剛剛不小心推錯 commit 到新的 branch 上面,因為只有這個 commit,就想說直接把 branch 給刪掉就好。 git branch -D wip/foobar 但是到 gitlab 上看 branch 還是存在於 remote 端。 回到 cli 下 git push 卻告訴我 Already up to date…… 上網看了一下,要把 branch 推回 remote 端才行 git push origin wip/foobar 搞定!