将一个步骤中的多个分支或标记与给定的refspec匹配到另一个远程

时间:2014-08-12 13:45:48

标签: git git-remote

假设我有以下分支

refs/heads/master
refs/heads/x
refs/heads/y
...
refs/heads/features/a
refs/heads/features/b
refs/heads/features/c
refs/heads/features/d
..

现在我想将位于refs/heads/features/*的所有分支推送到另一个远程(我已配置),以便它们以相同的名称结束在远程控制器上。但我不想xy。这是可能的,如果是的话,我如何为标签做同样的事情?

我知道git push --all可以使用,但它不是我想要的。

1 个答案:

答案 0 :(得分:2)

您可以使用glob配置refspec。

git push <remote_name> 'refs/heads/features/*:refs/heads/features/*'

如果您希望强制推送所有分支,则使用+添加refspec。如果要配置默认情况下始终为特定远程控制该refspec,则可以使用以下命令在本地.git/config中对其进行配置。

git config --add remote.<remote_name>.push 'refs/heads/features/*:refs/heads/features/*'

现在使用git push <remote_name>时没有其他参数,默认情况下它将使用该refspec。

再次,这是一个用力推动遥控器的例子。

git push <remote_name> '+refs/heads/features/*:refs/heads/features/*'