I am novice in dealing with git, but I have a repository that contains a file named \'test\'. I want to check if that specific file has changed. Is there anyway to do that?
As it was correctly mentioned in the answer of Peter Lundgren,
git commands are intended to be run against a local repository,
so git clone
is likely to be called anyways.
On the other hand, if you need to check if you want to trigger some specific CI step, you might find useful something like this in your script:
if git diff --quiet $COMMIT_HASH^! -- . ':!test'; then
echo "No significant changes"
else
echo "There are some significant changes, let's trigger something..."
fi
--quiet
disables all output of the program and implies --exit-code
(see git documentation).
Reference this answer for more details regarding the pattern at the end of the expression.