Search code examples
gitgithubrepositorypatch

Make patch or git diff of Github issue commits?


In the following Github issue are there 35 commits

How can I get a copy of those commits as patches or git diff's, so I can keep a local copy?

From what I can tell, not all commits have been accepted, but I like to have a copy of them all anyway.

This question is different from this, as the commits in that answer have all been committed.


Solution

  • You can usually do this by adding the word .patch or .diff onto the end of the url, i.e.:

    https://patch-diff.githubusercontent.com/raw/overleaf/web/pull/103.diff

    However it appears that (I think) because the original repository isn't present, this doesn't work.

    This also precludes manually cloning the original repo and then creating a patch from there on the command-line.

    However you can get access to the branch containing a PR by doing the following:

    git clone https://github.com/sharelatex/web-sharelatex
    cd web-sharelatex
    # edit .git/config - change the 'origin' fetch entry to:
      fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
    git fetch -a
    git checkout remotes/origin/pr/103
    

    You can now get access to all the commits in that PR and generate patches etc.