简体   繁体   中英

Auto push any changes in any local branch to remote repo using git hook

I have 5 developers pointing to local git server.

What i want is if someone push to local git server then it should automatically push that changes to remote repository (eg. bitbucket) including any changes into any branch.

Just like identical copy of my local git server.

Q : Can i do using git hooks or any third party tools like Jenkins? (if yes then how)

Hi and Happy New Year!

You have already stated it in the question: you need a git hook. More precisely, post-receive hook .

In your bare repository there should be hooks/ directory and you should put your post-receive script there.

In the most simple scenario you just run git push --all my_upstream_repo in this script. You should have upstream repo already defined via git remote .

PS. Using Jenkins would be an overkill; also, you'd need to inform Jenkins that some changes arrived at your local repository, so it's not buying you anything - you need a hook anyway. You can simply run another push in your hook instead of using any 3rd party tool which would need to be notified anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM