簡體   English   中英

我可以在git的單個命令中推送到多個存儲庫嗎?

[英]Can I push to more than one repository in a single command in git?

基本上我想做一些像git push mybranch to repo1, repo2, repo3

現在,我只是多次鍵入push,如果我急於完成推送,我會將它們全部發送到后台git push repo1 & git push repo2 &

我只是想知道git本地支持我想做的事情,或者那里是否有一個聰明的腳本,或者是一種編輯本地repo配置文件的方式,說應該將分支推送到多個遠程站點。

即使git remote命令沒有顯示我檢查過的最后一個,您也可以在git中為每個遙控器設置多個URL。 .git/config ,輸入以下內容:

[remote "public"]
    url = git@github.com:kch/inheritable_templates.git
    url = kch@homeserver:projects/inheritable_templates.git

現在您可以說“ git push public ”立即推送到兩個存儲庫。

我要做的是只有一個裸存儲庫,該存儲庫位於我推送到的主目錄中。 然后,該存儲庫中的更新后掛鈎會將推送或rsync推送到其他幾個公開可見的位置。

這是我的鈎子/更新后:

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, make this file executable by "chmod +x post-update".

# Update static info that will be used by git clients accessing
# the git directory over HTTP rather than the git protocol.
git-update-server-info

# Copy git repository files to my web server for HTTP serving.
rsync -av --delete -e ssh /home/afranco/repositories/public/ afranco@slug.middlebury.edu:/srv/www/htdocs/git/

# Upload to github
git-push --mirror github 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM