Compare old and new versions of force-pushed GitHub pull request

前端 未结 4 1611
忘掉有多难
忘掉有多难 2021-02-04 00:37

Frequently, my colleagues will make some changes to an open pull request, rebase their local branch against the base branch - often squashing their changes into previous commits

4条回答
  •  旧时难觅i
    2021-02-04 01:06

    The following works, but is inefficient for large repos because the whole repo worktrees are downloaded:

    repo=rossant/awesome-math
    a=61e250
    b=2b53ad
    tmp=$(mktemp -d -p /tmp)
    mkdir -p $tmp/{a,b}
    curl -SL https://github.com/$repo/archive/$a.tar.gz | tar xz --strip-components=1 -C $tmp/a
    curl -SL https://github.com/$repo/archive/$b.tar.gz | tar xz --strip-components=1 -C $tmp/b
    git diff --no-index $tmp/{a,b}
    rm -r $tmp
    

    This could be much simpler and leaner if Github would allow git fetching revs by their SHA1, but that's not the case yet.

提交回复
热议问题