git Push 后复制未版本控制的文件
我有一个每天工作的本地存储库和一个我推送结果的远程裸存储库。我想在每次推送后将一些不受版本控制的本地文件(例如 .exe 和 .dll 文件)复制到同一服务器上的单独目录(例如 bin 目录)中,这可能吗? 我尝试使用钩子,但它们在服务器端工作,因此我不知道如何判断要复制的文件在哪里。
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-side, hence I don't know how to tell where the files to copy are.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
git 的钩子不一定是“服务器端”——您可以在任何存储库中拥有钩子。但是,在您从存储库执行 git push 后,并没有专门运行的钩子。可能足够接近的是
post-commit
钩子,这样每次您在本地创建提交时,您都可以复制.exe
和.dll< /code> 文件到一个单独的目录中。
但是,如果您确实只想在推送后进行复制,最简单的解决方案可能是设置 git 别名。例如,如果您执行:
... 您可以在存储库中执行:
... ,如果推送成功,文件将被复制。 (我还没有测试过该别名,但我认为这是正确的。)
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 apost-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:
... you can just do:
... 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.)