简体   繁体   English

从Subversion过渡到Git,我如何优雅地推送到heroku?

[英]Transitioned from Subversion to Git, how do I push to heroku gracefully?

I had been using a Subversion for my source control, combined with git ONLY to deploy (push) to heroku. 我一直在使用Subversion进行源代码控制,仅与git结合使用才能将其部署(推送)到heroku。 My pattern was: Update local working copy from latest master at remote subversion repository. 我的模式是:从远程Subversion存储库中的最新主更新本地工作副本。 Then do git commit and git push heroku (Git was set to ignore .svn stuff). 然后执行git commit和git push heroku(Git设置为忽略.svn内容)。 This working copy I only used to push to heroku, I had another subversion folder for doing live development, and committing to the remote subversion repository for tracking. 这个工作副本我仅用于推送到heroku,我还有另一个Subversion文件夹用于进行实时开发,并提交到远程Subversion存储库进行跟踪。

I have now switched to git fully. 我现在已经完全切换到git。 I did a complete import from subversion into a new remote git repository. 我从Subversion完全导入了新的远程git存储库。 I've successfully been working on my local working copy of the git repo (origin), and pushing changes when it suits me (also collaborating with one other developer, but I basically run the operation). 我已经成功地在本地git repo(源)的工作副本上工作,并在适合我的时候推送更改(也与其他开发人员合作,但我基本上是运行该操作)。

MY Question: 我的问题:

I would now like to return to my OTHER git working copy that I had previously been using to push to heroku (that has .svn/ stuff in it as well). 现在,我想返回到我以前用来推送到heroku的OTHER git工作副本(其中也包含.svn /内容)。 I'm thinking of just adding my new git repository as an [origin] entry in the .git/config.. pulling the latest changes from my new git remote, and pushing to heroku, but I'm wondering if it will freak out. 我正在考虑只是将新的git存储库添加为.git / config中的[origin]条目。从新的git远程获取最新更改,并推送到heroku,但我想知道它是否会发疯。

It will try and merge and get confused won't it? 它将尝试合并并感到困惑,不是吗? AND, even if the pull worked, will the heroku remote get confused about a push that originated from some new git repo? 而且,即使拉动有效,heroku遥控器是否也会对源自某些新git repo的推动感到困惑?

I could clobber (delete) that working copy (used to push to heroku from subversion), and make a new clone of my new git repository, then add heroku to the .git/config. 我可以破坏(删除)该工作副本(用于从Subversion推送到heroku),并为我的新git存储库创建新的克隆,然后将heroku添加到.git / config中。 But I'm concerned pushing to heroku will still cause it to get confused, since I used to push from a different working copy. 但是我担心推送到heroku仍然会使它感到困惑,因为我曾经从另一个工作副本中推送。

Any advice would be great! 任何建议都很好!

Thanks in advance! 提前致谢!

If I understand you correctly, you want to switch back to the former SVN repository as your working copy, and you want to preserve the old SVN history? 如果我对您的理解正确,那么您想切换回以前的SVN存储库作为工作副本,并且要保留旧的SVN历史记录?

There are a couple of options available. 有几个可用的选项。

  1. Push the recent changes from the new Git repository to Heroku, then switch to the old repository and pull from Heroku. 将最近的更改从新的Git存储库推送到Heroku,然后切换到旧的存储库并从Heroku拉出。 This will bring you old repository up to date. 这将使您的旧存储库保持最新状态。

  2. Temporarily change the URL in the old repository's config file to point to the local path of the new repository. 临时更改旧存储库的配置文件中的URL,以指向新存储库的本地路径。 Pull the recent changes from there, and then revert back to the Heroku URL when done. 从那里拉出最近的更改,然后在完成后还原回Heroku URL。 This will also bring your old repository up to date. 这还将使您的旧存储库保持最新状态。

The first option is the most expedient, and the second is the long way round. 第一个选项是最方便的选择,第二个是很长的路要走。 Either way, you will have the same net result of an up to date local repository containing all history. 无论哪种方式,您都将获得包含所有历史记录的最新本地存储库的相同净结果。 The surplus new repository can be disposed of in either case. 在任何一种情况下都可以处置多余的新存储库。

Edit: To address your concerns about whether Heroku will care about the origin of the commit, in brief, no the repository on Heroku is another git repository that accepts commits from authenticated users. 编辑:要解决您对Heroku是否会关心提交源的担忧,总之,Heroku上的存储库不是另一个git仓库,它接受经过身份验证的用户的提交。

As long as the credentials are correct, the originating repository does not matter. 只要凭据正确,原始存储库就无关紧要。 This is the beautiful thing about DVCS - there is not one controlling or corruptible repository - It is entirely possible for you to now clone from Heroku on another machine and continue work from there. 这是DVCS的妙处-没有一个可控制的或可损坏的存储库-您现在完全有可能从另一台计算机上的Heroku中克隆并从那里继续工作。 As long as your credentials are the same, the history will show any and all commits you push, but does not care where from. 只要您的凭据相同,历史记录就会显示您推送的所有提交,但不在乎从何处提交。

If your desire is to simply use a clean repository to work with, the new one will be the favorite. 如果您只是想使用一个干净的存储库来工作,那么新存储库将是您的最爱。 The old one can be deleted without ill effects. 可以删除旧版本而不会造成不良影响。

To prove this - check the SHA-1 hashes for a commit in both new and old repositories, and you will see they are identical. 为了证明这一点-在新存储库和旧存储库中检查SHA-1哈希是否有提交,您将看到它们是相同的。 The hash is unique for all commits, and can be used to check the code integrity at all times. 哈希对于所有提交都是唯一的,并且可以随时用于检查代码完整性。 There will never be more than one change for any given hash. 对于任何给定的哈希,永远不会有一个以上的更改。

  • As a side note, the repository is portable in that it is entirely self contained, and can be moved around freely on your storage space, or even be used on external storage such as a USB thumb drive. 附带说明一下,该存储库是便携式的,因为它完全是独立的,可以在您的存储空间中自由移动,甚至可以在外部存储设备(例如USB拇指驱动器)上使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM