作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试在 Heroku 上创建一个暂存分支,但有些事情我不太明白。
假设我已经创建了一个 heroku 应用程序并将 Remote 设置为指向 staging-remote,如果我这样做:
git checkout -b staging staging-remote/master
我有一个名为“staging”的本地分支,它跟踪 staging-remote/master - 或者这就是我的想法....
但是:
git remote show staging-remote
给我这个:
remote staging
Fetch URL: git@heroku.com:myappname.git
Push URL: git@heroku.com:myappname.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
staging-remote merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
如你所见,pull 看起来合理,但默认的 push 却不合理。这意味着如果我这样做:
git push 暂存远程
我要将我的本地 master 分支推送到 staging 分支。但这不是我想要的......基本上,我想将更新 merge 到我的暂存分支中,然后轻松地将它推送到 heroku 而不必像这样指定分支:
git push staging-remote mybranch:master
上面的并不难做,但是我想避免不小心把之前的push推错了分支...这对于我想创建的生产分支来说是加倍重要的!
我试过搞乱 git 配置,但还没有想出正确的方法...
最佳答案
我已经测试过了,@juba 和@MatthewFord 的版本运行完美!
git config remote.staging.push staging:master
这会将名为 staging 的本地主题分支推送到名为 staging 的远程存储库上的远程分支 master。
@nickgrim 像这样把它放在一般形式中:
git config remote.[remoteRepositoryName].push [localBranchName]:[remoteBranchName]
更新:
此外,当您使用 -u
选项 git push
时,现代 git 将方便地为您运行上述配置命令:
git push -u staging staging:master
关于Git 使用 Heroku 将当前分支推送到远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2401254/
我是一名优秀的程序员,十分优秀!