开发者

Copy unversioned file after git push

开发者 https://www.devze.com 2023-04-11 20:04 出处:网络
I have a local repository where I work daily and a remote bare repository where I push my result. I would like after every push to copy some local files that are not under version control (like .exe a

I have a local repository where I work daily and a remote bare repository where I push my result. I would like after every push to copy some local files that are not under version control (like .exe and .dll files) into a separate directory (bin directory for example) on the same server, is it possible? I tried with hooks but those work server-s开发者_运维百科ide, hence I don't know how to tell where the files to copy are.


git's hooks aren't necessarily "server-side" - you can have hooks in any repository. However, there isn't a hook which is run specifically after you've done a git push from a repository. Something that might be close enough is a post-commit hook, so that every time you create a commit locally, you could copy the .exe and .dll files into a separate directory.

However, if you really do just want to copy after pushing, the simplest solution might be to set up a git alias. For instance, if you do:

git config alias.push-and-copy \
    '!sh -c "git push origin master && cp *.dll *.exe ~/bin"'

... you can just do:

git push-and-copy

... in your repository, and the files will be copied if the push was successful. (I haven't tested that alias, but I think that's right.)

0

精彩评论

暂无评论...
验证码 换一张
取 消