Result of lots of searching on net is that pre-checkout
hook in git is not implemented yet. The reason can be:
Here my problem is:
I have implemented the pre-commit
, post-merge
& post-checkout
hooks for maintaining the database backup different for each branch.
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.
So in this case I want a pre-checkout
hook to handle the task of backing up database in above scenario.
If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
To enable (or disable) hooks for repositories in a project (requires project admin permissions): Go to Project settings > Hooks. Click the toggle by the hook to enable (or disable) it.
You could write a script that does your backup then checkout. Then create a shell alias so it runs that script instead when you type git checkout
.
Pre-checkout use case: delete un-versioned local files generated by gulp watch:css
task so they are overwritten after checkout and rebuilt by gulp.
Instead, I'm just going to write a shell script that gets the repo root and then deletes any of a list of gulp-generated files found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With