How can I see what I am about to push with git?

前端 未结 14 2085
北恋
北恋 2020-11-27 09:06

Is there a way to see what would be pushed if I did a git push command?

What I\'m picturing is something like the \"Files Changed\" tab of Github\'s \"p

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 09:25

    Just to add my two cents... I wanted to implement this when running jobs in a gitlab pipeline on a gitlab runner. The best way to do this was to use this script:

    git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA
    

    Also in my case I wanted to filter files by extension, to achieve this I used:

    git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA '*.py'
    

    After that you can for example forward this list somewhere else, a linter perhaps ;)

    Hope this will help someone.

提交回复
热议问题