Auto push after git commit

Git hook allow you to perform tasks when some changes happen on a git repository. To automatically push code when you make a commit, create hook file .git/hooks/post-commit

1vi .git/hooks/post-commit

Add

1
2
3
#!/bin/sh 

git push origin master

Thats all. Unlike normal bash scripts, git hooks don’t need 755 permission to run. Example

[root@lin vshare]# cat .git/hooks/post-commit

!/bin/sh

git push origin master
[root@lin vshare]# ls -l .git/hooks/post-commit
-rwxrwxrwx 1 root root 37 Apr 27 15:31 .git/hooks/post-commit
[root@lin vshare]#

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat