Check diff when using actions/Checkout

I want to konw the diff comparing to the last commit in a Github Actions workflow.

With Checkout@v1, I can obtain the whole repo, therefore I can call “git diff HEAD^” to check the diff. However, it downloads the whole repo, which takes much longer time when dealing with a repo with a long history.

With Checkout@v2, it only downloads the current commit, and “.git” directory is not downloaded, therefore “git diff HEAD^” can not execute.

I wonder if there is an easy way to checkout the diff.

When use Checkout@v2, only a single commit is fetched by default, for the ref/SHA that triggered the workflow. Set fetch-depth to fetch more history. In your case, you could set fetch-depth=2. Then you could run 

git diff HEAD^ HEAD to get the diff comparing to the last commit. 

Please see my example:

fetch depth.png