Reputation: 2160
I want to write a script that, after a git pull request, copies the pulled files to a different location.
I understand that I need to put the request in one of the hook files, either post-pull
, post-merge
or post-update
.
I am however not sure how I will see which files are newly added with the pull and how to copy those files.
Upvotes: 1
Views: 556
Reputation: 3382
А simple way is to create an alias for your git commands, which calls a wrapper script. The wrapper script will perform the git command and then use the specified parameters e.g. the filename for the copy operation.
Upvotes: 0
Reputation: 38639
post-update
is executed after a push was done on the remote repository where you pushed to. post-pull
does not exist. What you want is post-merge
if you use pull
with merge
, or post-rewrite
if you use pull
with rebase
. But be aware that those hooks are not only called on pull
, but on any merge
, respectively on any rewriting commit like git commit --amend
and so on. So you might want to add some additional condition as to when to execute your additional actions.
To find the changed files in the post-merge
hook, you need to use normal Git commands, like git diff master@{1} master --name-status
or similar.
Upvotes: 1