如何在Git/bitbucket中实现“预检"挂钩? [英] How to achieve 'pre-checkout' hook in Git/bitbucket?
问题描述
网上大量搜索的结果是git中的pre-checkout
钩子尚未实现.原因可能是:
Result of lots of searching on net is that pre-checkout
hook in git is not implemented yet. The reason can be:
- 没有实际用途. 我有案子
- 可以通过任何其他方式实现. 请告诉我如何?
- 实施起来太困难了. 我认为这不是正当理由
这是我的问题:
我已经实现了pre-commit
,post-merge
& post-checkout
挂钩,用于维护每个分支不同的数据库备份.
I have implemented the pre-commit
, post-merge
& post-checkout
hooks for maintaining the database backup different for each branch.
场景:现在,当我提交数据库备份时,使用pre-commit
钩子将数据库的备份保存在文件中.当我结帐分支或合并时,使用post-merge
& post-checkout
钩子.现在的情况是,如果有人在提交和签出后对数据库进行了更改,则更改将丢失,因为未备份数据库.由于文件结构没有更改,因此检出成功.
Scenario: Now when I commit the backup of database is saved in a file using pre-commit
hook. And when I checkout the the branch or merge occurs the database stored in file is restored using post-merge
& post-checkout
hooks. Now the situation is if someone make changes in database after commit and checkout, the changes are lost, as database was not backed-up. The checkout succeeded as there is no change in file structure.
因此,在这种情况下,我希望使用pre-checkout
钩子来处理上述情况下的数据库备份任务.
So in this case I want a pre-checkout
hook to handle the task of backing up database in above scenario.
推荐答案
我知道未实现它的原因.在我的情况下,我确实备份了数据库并将其存储在文件中,该文件每次都无法通过检出.因此,要实现此功能将是不切实际的.
I got the reason why it was not implemented. In my situation I do backup the database and store it in a file, which will fail the check-out every-time. So this will be impractical to implement this functionality.
这篇关于如何在Git/bitbucket中实现“预检"挂钩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!