2013-12-12 30 views
1

这工作我“主人”分支推到远程分支,“生产”如何设置执行以下操作的refspec?

git push origin master:refs/heads/production 

但是,我怎么救远程位置,所以我可以简单地做git push production master?我不想在本地生产分支。这是发展,直到我推高它。然后我只想做

git merge production 

在服务器上抓取最新的副本。

回答

0

如果你

git push -u origin master:refs/heads/production 

Git会记得上游分公司(-u代表 “上游集”)。

+0

这是如何工作的? '分支主人设置为从原点追踪远程分支生产。一切都是最新的' –

+0

该设置存储在'.git/config'中。 –

+0

这不是我想要的。上面的代码片段将原始分支推送到远程分支生产。我不想惹我的主分支。 –

2

我不认为你可以完全得到你想要的东西(用“你想要什么”是git push production master)在这里,但你可以得到的东西稍微简单的两个配置项:

git config remote.production.url ssh://... 
git config remote.production.push master:production 

,其后:

git push production 

会推到指定的网址(请注意:您可以设置remote.production.pushurl作出专门的网址为production取和推送,但是这可能不是在这里需要)。由于没有遥控器后的参考,git push会咨询remote.production.push来设置一个。因为 a remote.production.push它将使用该代替任何配置的branch.master.remotebranch.master.merge(如果存在的话)或remote.pushdefault(如果那些不存在)。

的这里的缺点是,如果你不小心写:

git push production master 

然后git push会看到你指定一个的Refspec而忽略remote.production.push。指定的refspec相当于(完整的,延伸版本)refs/heads/master:refs/heads/master


要避免的,而不是摆弄所有这些事情,去年的缺点,你可以简单地配置一个别名,如:

git config alias.pushprod "push origin master:production" 

,其后:

git pushprod 

是一个更简单的方法来“输入”已经工作的完整命令。

相关问题