Reputation: 422
I have a server on which I send the results of my work. After each command git push
I have to connect via SSH and enter the command to switch my remote repository to the latest version:
git checkout NNNN
Can I simplify this action?
P.S. Before submitting of this question I had found some information about GitHooks. Can I use it for my task described above and, for example for restarting Rails server after checkout?
Upvotes: 3
Views: 2520
Reputation: 18000
Before first commit into remote repo to avoid error: refusing to update
I forced to do:
git config receive.denycurrentbranch ignore
To enable auto checkout it is enought to set
git config receive.denycurrentbranch updateInstead
Upvotes: 1
Reputation: 33412
Sure, you can simplify it!
Suppose, you are using Github. Create a webservice, accessible from the web with the language of your choice. The service will need to accept requests like this and do the work you need. After it is created go Github. In your project's settings go to Settings
and then to Service Hooks
. You'll need to add WebHook URL
. Enter the URL of your service. That's all. Bitbucket also has such feature, named Service
in admin area of your project. You need to create POST
service to do this.
If you host your repo on your own server, you can use post-update
hook.
There is no post-push
hooks, or something similar to it, so you cannot simply trigger jobs on your local machine.
Upvotes: 2