all repos — website @ adeb187f343787f516c6e7d7ce533311f68dff4a

personal website hosted at prithu.xyz, built using hugo

add licence
Prithu Goswami prithugoswami524@gmail.com
Mon, 21 Dec 2020 18:26:04 +0530
commit

adeb187f343787f516c6e7d7ce533311f68dff4a

parent

5be5df6c99bcd544798f4a7d94a750dd24013982

2 files changed, 44 insertions(+), 2 deletions(-)

jump to
M content/posts/git-remote-hooks.mdcontent/posts/git-remote-hooks.md

@@ -17,7 +17,7 @@

Setting up a remote git repository on the VPS is as easy as doing: ``` -git init --bare website.git +git init --bare website ``` Usually it's a practice of creating a new user called 'git' on your server to

@@ -41,7 +41,7 @@ If I already have a local repository, then I just push to this new one by

adding it as a remote using: ``` -git remote add myserver git@git.prithu.xyz:website +git remote add myrepo git@git.prithu.xyz:website ``` I can also initialize a new repo and add a remote to it manually.

@@ -55,5 +55,26 @@ $ git commit -am 'Initial commit'

$ git push origin master ``` +## Understanding hooks + +A hook is basically code that runs as a result of some event. In git we have +client-side hooks and server-side hooks. Client-side git hooks run on your +machine when perform actions on your local git repo. `pre-commit` is a +client-side hook that runs before you commit something, you can use this hook +to check for what is being commited and run tests for example to check if the +formating of the code conforms to a style guide. `post-merge` runs after a +successful merge takes place. `commit-msg` - This hook is invoked on `git +commit` and gets the name of the file that holds the commit message. Checks can +be performed on the commit message to see whether or not it conforms to a +standard format. If the hook exits with a non-zero cdoe, the commit is aborted. + +We also have server-side hooks that live on the remote's bare repository. +`pre-recieve` hook runs before refs are updated on the remote. The script can +exit with a non-zero code and the push won't be accepted and the client will be +notified. `post-recieve` on the other hand runs when all the refs are updated +on the remote. This hook can be thought of as a hook that runs when there is a +'push'. This hook gets information of what refs were updated - if the master +branch was updated then this information is passed on to the script along with +the last hash and the new updated hash.
A licence

@@ -0,0 +1,21 @@

+MIT License + +Copyright (c) 2020 Prithu Goswami <prithugoswami524@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.