将Heroku App导出到新的GitHub存储库 [英] Export Heroku App to a new GitHub repo

查看:56
本文介绍了将Heroku App导出到新的GitHub存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Heroku CLI 部署的Heroku项目,我想在我的GitHub帐户上的 new 存储库中转移该项目,但是对于这些远程处理"的工作方式确实感到困惑.我只发现有人试图做相反的事情(从GitHub存储库到Heroku应用).

I have a Heroku project which I deploy using the Heroku CLI and I would like to transfer this project in a new repo on my GitHub account but I'm getting really confused about how these "remotes" work. I've only found people trying to do the opposite (from GitHub repo to Heroku app).

推荐答案

远程"几乎只是一个名称和几个URL.URL通常是相同的.您可以通过在项目目录中运行 git remote -v 来查看现有的遥控器,例如

A "remote" is pretty much just a name and a couple of URLs. The URLs are often the same. You can see your existing remotes by running git remote -v in your project directory, e.g.

$ git remote -v
origin  https://github.com/github/hub.git (fetch)
origin  https://github.com/github/hub.git (push)

这里我有一个远程的 origin ,其 fetch push URL相同.

Here I have one remote, origin, whose fetch and push URLs are the same.

如果在存储库中运行该命令,则可能至少会看到一个名为 heroku 的远程指向位于Heroku下方的Git主机( https://git.heroku.com/... ).这就是Heroku CLI用来部署应用程序的方式.

If you run that command in your repository you will probably see at least a remote called heroku pointing at the Git host that underlies Heroku (https://git.heroku.com/...). This is what the Heroku CLI uses to deploy your application.

您需要为GitHub存储库添加一个新的远程服务器.如果还没有,请在GitHub上创建一个新的存储库以包含您的项目.不要使用自述文件, .gitignore LICENSE 文件¹来初始化项目.记下URL完成此操作后,GitHub会显示给您.

You need to add a new remote for your GitHub repository. If you haven't already, create a new repository on GitHub to contain your project. Do not initialize the project with a README, .gitignore, or LICENSE file¹. Make note of the URL that GitHub shows you after you've done this.

现在添加新的存储库作为远程服务器,并使用一个有意义的名称:

Now add the new repository as a remote with a name that makes sense:

git remote add <name> <github-url>

您现在可以使用 git push< name> 推送到新的遥控器.

You can now push to the new remote using git push <name>.

常规GitHub访问规则适用-您需要设置SSH密钥或提供密码.如果您使用 2FA 并要使用HTTPS,您需要设置个人访问密码,并使用该密码代替您的密码.

Regular GitHub access rules apply—you'll need to have an SSH key set up or provide your password. If you use 2FA and want to use HTTPS you'll need to set up a personal access code and use that instead of your password.

¹如果创建这些文件,则会在本地副本上不存在的GitHub上提交新的提交.在这种情况下,您将无法进行常规推送.

¹If you create these files you'll end up with a new commit on GitHub that doesn't exist in your local copy. In this case you won't be permitted to do a regular push.

这篇关于将Heroku App导出到新的GitHub存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆