0

GitLab run pipeline on git push. While running this pipeline I would like get list of files which are going to be pushed from all commits if there are multiple commits happend.

I am trying to get using this command

git diff-tree --no-commit-id --name-only -r ${CI_COMMIT_SHA} but this is giving only recent commit only. If there are more than one commit happend in the branch it is giving only last commit details. I would like to get all files which are committed during that push.

When git is able to find all the files from multiple commits which it needs to push , how can not we?

4
  • Possible duplicate: stackoverflow.com/questions/9315024/… Commented Aug 13, 2018 at 5:55
  • I do not know the pattern here becuase I might not be the person who is going to commit. Commented Aug 13, 2018 at 6:01
  • ok, so this is what I understand, you want to see all files in which changes are made over multiple commits, am I right ? Commented Aug 13, 2018 at 7:55
  • 1
    Possible duplicate of git list changed files in several commits Commented Aug 14, 2018 at 6:09

2 Answers 2

1

This will solve my issue.

git whatchanged --name-only --pretty="" origin..HEAD

UPDATE: Above command also includes changes made to master through other branch. Let's say some one else pushed code changes to master and you did not pull them then when you run the above command, it shows those changes as diff in your current branch.

I think whatchanged is deprectated you can replace it with log

If you want to view changes only from your current branch , you can use this git diff master... --name-only or git diff --name-only master...<branch_name>

Sign up to request clarification or add additional context in comments.

1 Comment

yeah, that was another good solution, didn't thought about that.
0

to view file changes between a given commit and your current commit use -

git diff --name-only <starting SHA> HEAD

and on being more general to your problem, to check which files changed between two commits do -

git diff --name-only <commit1> <commit2>.

3 Comments

Thanks for your reply. In the above commands, How can I find <starting SHA> ? I do not have any idea about the current branch. I am like a third person who wants to check files which are going to be pushed and run some script on those files.
<starting SHA> means hash code of respective commit from which you want to view files.
His question is how to know what the last commit was since the last push.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.