Git - 使开发和掌握不同的回购。明智?

时间:2011-05-09 16:39:34

标签: git heroku staging

我有一个git中的项目并部署到heroku。远程URL为git@heroku.com:myappname.git,.git / config如下所示:

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  url = git@heroku.com:myappname.git
[branch "master"]
  remote = origin
  merge = refs/heads/master

我刚刚创建了一个名为“myappname-staging”的新的heroku应用程序,我想将其用作此应用程序的临时站点。我想我会设置它以便“master”分支推送到生产遥控器并且“development”分支推送到staging遥控器。这是处理这种情况的合理/传统方式吗?

我无法弄清楚如何做到这一点。当我在heroku上制作临时应用程序时,它给了我这个回复:

Creating myappname-staging.... done
http://myappname-staging.heroku.com/ | git@heroku.com:myappname-staging.git
Git remote heroku added

我的配置现在看起来像这样:

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  url = git@heroku.com:myappnamestef.git
[branch "master"]
  remote = origin
  merge = refs/heads/master
[remote "heroku"]
  url = git@heroku.com:myappname-staging.git
  fetch = +refs/heads/*:refs/remotes/heroku/*
[remote "staging"]
  url = git@heroku.com:myappname-staging.git
  fetch = +refs/heads/*:refs/remotes/staging/*

有人能帮我直接吗?

谢谢,最大

1 个答案:

答案 0 :(得分:5)

添加:

[branch "development"]
  remote = staging
  merge = refs/heads/master

您可以通过命令行执行此操作:

$ git config branch.development.remote staging
$ git config branch.development.merge refs/heads/master

这会将development分支设置为在暂存时跟踪master分支。