How to find all changed files since last commited build in GIT ? I want to build not only the changed files at head revision but also, all the changed files which got changed before that as well since last successful build.
git show --pretty="format:" --name-only will do the build only for top commit changed files. Like this, i need to build for all changed files in different commits since last successful build.
Like , last build done in Jenkins at X SHA-1 id, and after that , there are 3 more commits on top of it. So, my aim is to checkout whole repository codebase till head and then find out list of all files which got changed after X SHA-1 id , that are 3 commits on top of last commit at X SHA-1 id ?
Thanks
You can use the changeSets property of the currentBuild global variable to get information relating to the detected changes of the current build.
Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command.
If you just want to see the diff without committing, use git diff to see unstaged changes, git diff --cached to see changes staged for commit, or git diff HEAD to see both staged and unstaged changes in your working tree.
Little late to the party but a slightly better way is to use the --name-only
functionality on git diff. What I used is as follows:
git diff --name-only $GIT_PREVIOUS_COMMIT $GIT_COMMIT
This way you don't have to do some piping work afterward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With