git finding duplicate commits (by patch-id)

后端 未结 7 1803
天命终不由人
天命终不由人 2020-12-16 02:05

I\'d like a recipe for finding duplicated changes. patch-id is likely to be the same but the commit attributes may not be.

This seems to be an intended use of patch-

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 02:12

    For anyone wanting to do this on windows powershell the equivalent command to unagi's answer is:

    git rev-list --no-merges --all  | %{&git.exe show $_} | 
      git patch-id | ConvertFrom-String -PropertyNames PatchId, Commit | 
      Group-Object PatchId | Where-Object count -gt 1 | 
      %{$_.group.Commit + " "}
    

    Gives an output like:

    1605e0e1e13d7b3f456c20432d8edec664ca7117
    1e8efa8f2f01962a2c08fd25caf687d330383428
    
    b45b6db084b27ae420ac8e9cf6511110ebb46513
    4a2e1e3ba5a9a1d5db1d00343813e1404f6124e2
    

    With the duplicate commit hashes grouped together.

    CAUTION: On my repo this was a slow command so be sure to filter the call to rev-list appropriately!

提交回复
热议问题