简体   繁体   English

将项目移至其他git托管

[英]Moving a project to a different git hosting

I have my project hosted at bitbucket. 我的项目托管在bitbucket上。 Now I am open sourcing it and want to move it to github. 现在,我将其开源,并希望将其移至github。 I have already created an empty github repository, but when I locally on my computer change the remote url to the new repo, it shows no changes and won't commit/push anything. 我已经创建了一个空的github存储库,但是当我在本地计算机上将远程URL更改为新的存储库时,它不会显示任何更改并且不会提交/推送任何内容。 I am clearly doing it wrong - what is the correct way of moving a project from one git repository/server to another one? 我显然做错了-将项目从一个git存储库/服务器移至另一个的正确方法是什么?

I'm assuming that your Github repository is empty. 我假设您的Github存储库为空。

In your local folder, add a new remote repository: 在本地文件夹中,添加一个新的远程存储库:

git remote add github git@github.com:<username>/<repository>.git

Alternatively, if you did not set your ssh key on Github, you should use HTTPS: 另外,如果您未在Github上设置ssh密钥,则应使用HTTPS:

git remote add github https://github.com/<username>/<repository>.git

Push your local master branch to the Github reposiroty: 将您的本地分支推送到Github仓库:

git push github master

You will want to add the GitHub repo as a new remote to your existing local repo. 您将需要将GitHub存储库添加为现有本地存储库的新远程目录

See this QA: Git: how to set remote in existing repo 查看此QA: Git:如何在现有仓库中设置远程

You may need to do a Force Push if your new GitHub repo already has commits, and those commits will be lost. 如果您的新GitHub存储库中已有提交,则可能需要强制执行,这些提交将丢失。

Note that you could just set your existing BitBucket repo to public. 请注意,您可以将现有的BitBucket存储库设为公开。 GitHub does not have a monopoly on open-source projects. GitHub在开源项目上没有垄断。

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

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