有没有办法同步 Coding 与 GitHub
高洛峰
高洛峰 2017-04-21 10:57:35
0
3
654

如果一个项目同时在 GitHub 和 Coding 上都有仓库,能不能一次 commit 就可以更新到两个地方?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
PHPzhong

Git push to multiple warehouses at the same time

To prevent a git repository from being inaccessible due to various reasons, you can push the code to multiple repositories.

Edit the config file in the .git directory under the local warehouse directory.

Add:

[remote "all"]
url = git@github.com:licess/licess.git
url = git@gitcafe.com:licess/licess.git

When push again, run

git push all master
巴扎黑

You can use the git remote set-url command to achieve this, taking Coding and GitHub as examples:

$git remote -v #查看当前远端仓库
origin  git@git.coding.net:user/project.git (fetch)
origin  git@git.coding.net:user/project.git (push)
github  git@github.com:user/repo.git (fetch)
github  git@github.com:user/repo.git (push)


$git remote add both git@git.coding.net:user/project.git
# 添加一个名为 both 的远端
$git remote set-url --add --push both git@git.coding.net:user/project.git
# 为其添加 push 到 Coding 的 SSH 地址
$git remote set-url --add --push both git@github.com:user/repo.git
# 为其添加 push 到 GitHub 的 SSH 地址

(Note that if you choose to use SSH to push, you must configure the SSH public key in advance)
You can then use git push both to push to two remote warehouses at the same time.

洪涛

Github supports hooks, you can set them up. Get a server and do this yourself. In this way, every time you push to github, the hook will be triggered to achieve automatic synchronization with gitcafe.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template