简体   繁体   中英

Git auto merge commits from another repo

I have 2 private repository (not branches) A and B of which I have full access to.

Whenever A makes a commit, I want B to cherry-pick or merge the new commit into it (assuming no merge conflicts), so that B will always be up-to-date with the latest changes from A .

How do I accomplish this with Git hook or something else?

A shell script is less flexible as it means you have to commit/push with command line rather than GUI (eg. with SourceTree ).

In repository A create a post-commit hook that switches to repo B and runs git pull .

The kind of "switching" depends on where B resides. If it's on the same computer the hook can just cd /path/to/B , but don't forget to clear GIT_DIR and GIT_WORK_TREE env vars before running git pull . If B is on another server the hook should ssh there.

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