2015年7月17日 星期五

[GIT] How to git push multi repository


Method 1:
Syntax :

git config alias.pushall '!f() { git push <remote-name> $1 && git push <remote-name> $1; }; f'

Example :

git config alias.pushall '!f() { git push origin $1 && git push openvpn $1; }; f'


Method 2:
Edit .git/config
[alias]
    pushall = "!f() { git push origin $1 && git push openvpn $1; }; f"
cat .git/config
[openvpn]$cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = ssh://
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "openvpn"]
    url = ssh://
    fetch = +refs/heads/*:refs/remotes/openvpn/*
[alias]
    pushall = "!f() { git push origin $1 && git push openvpn $1; }; f"

Add more repository
Example:

git remote add vpn ssh://gogo@192.168.0.1:/home/sasa/git/vpn.git
Reference:
  1. Git - Pushing code to two remotes [duplicate]

0 意見:

張貼留言