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
1 |
vi .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
1 2 3 4 5 6 7 |
[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]# |
See git