git 将 Bitbucket 存储库从一个帐户复制到另一个 bitbucket 帐户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20343615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy a Bitbucket Repository from one account to another bitbucket account
提问by erickhushwaha
my friend have a repository on Bitbucket and I want to copy that repository (for future reference so that if he delete that repository i would still have one copy) to my bitbucket account. I tried bare-cloning,mirror push and etc... but :(
我的朋友在 Bitbucket 上有一个存储库,我想将该存储库复制到我的 bitbucket 帐户(以供将来参考,以便如果他删除该存储库,我仍然会有一个副本)。我尝试过裸克隆、镜像推送等......但是:(
may be I'm missing some set of commands
可能是我缺少一些命令
PS: repository type is git (not hg)
PS:存储库类型是git(不是hg)
回答by Nitish Parkar
Recently, I had to do this for multiple repositories. I found a better way than cloning the repo locally and pushing it to another remote(on Bitbucket).
最近,我不得不为多个存储库执行此操作。我找到了比在本地克隆 repo 并将其推送到另一个远程(在 Bitbucket 上)更好的方法。
Bitbucket provides import repositoryfeature. It can be found under Repositories > Import Repository
Bitbucket 提供导入存储库功能。可以在下面找到Repositories > Import Repository
Just provide https url of the repo and access credentials, and bitbucket will do the rest for you.
只需提供 repo 的 https url 和访问凭据,bitbucket 将为您完成剩下的工作。
I know this is an old question but this method is easier and saves a lot of time. Hope this helps others in future.
我知道这是一个老问题,但这种方法更容易,而且可以节省大量时间。希望这可以帮助其他人将来。
回答by poke
If you have access to that repository, then simply cloning it to your local machine is all you need to do to get a full copy of it. For example:
如果您有权访问该存储库,那么只需将其克隆到本地计算机即可获得它的完整副本。例如:
git clone [email protected]:username/repository.git
Now, if you want to store a copy of it online, you can just create a new repository on Bitbucketwhere you push to. After filling out the form there, Bitbucket will give you a quick help on how to push your data inside. Choose “I have an existing project”and the following will show up:
现在,如果您想在线存储它的副本,您只需在 Bitbucket上创建一个新的存储库,然后将其推送到。在那里填写表格后,Bitbucket 将为您提供有关如何将数据推送到其中的快速帮助。选择“我有一个现有项目”,将显示以下内容:
Already have a Git repository on your computer? Let's push it up to Bitbucket.
cd /path/to/my/repo git remote add origin [email protected]:your_username/new-repo.git git push -u origin --all # pushes up the repo and its refs for the first time git push -u origin --tags # pushes up any tags
Want to grab a repo from another site? Try our importer!
您的计算机上已经有一个 Git 存储库?让我们把它推到 Bitbucket。
cd /path/to/my/repo git remote add origin [email protected]:your_username/new-repo.git git push -u origin --all # pushes up the repo and its refs for the first time git push -u origin --tags # pushes up any tags
想从另一个站点获取一个仓库?试试我们的进口商!
You just need to follow those instructions closely. You will have to choose a different remote name though as with your cloning, origin
is already taken:
您只需要严格按照这些说明进行操作。您将不得不选择一个不同的远程名称,尽管与您的克隆一样,origin
已经被采用:
git remote add mycopy [email protected]:your_username/new-repo.git
git push -u mycopy --all
git push -u mycopy --tags
Or you have to remove the origin
remote first:
或者你必须先移除origin
遥控器:
git remote remove origin
After pushing, your repository at Bitbucket will have the full contents, so your backup is ready.
推送后,您在 Bitbucket 的存储库将拥有完整内容,因此您的备份已准备就绪。
The other, and probably simpler, option is to simply fork your friends' repository directly. You can do that by visiting the Bitbucket page, then click the “…”icon in the top left and choose “Fork”. This will let you create a direct copy of the repository directly on Bitbucket.
另一种可能更简单的选择是直接分叉您朋友的存储库。您可以通过访问 Bitbucket 页面来实现,然后单击左上角的“...”图标并选择“分叉”。这将允许您直接在 Bitbucket 上创建存储库的直接副本。
回答by Isaac Brown
I would like to note that BitBucket has redesigned their site and the Import Repositoryfeature is now in the Create Repository(the '+' icon) menu as an option.
我想指出的是,BitBucket 重新设计了他们的网站,并且导入存储库功能现在作为选项位于创建存储库(“+”图标)菜单中。
You simply paste in the repository URL and check the box for Requires Authorizationand it should auto-fill your current login credentials and auto-populate the slug name. Change the slug to whatever you want and click import.
您只需粘贴存储库 URL 并选中需要授权的框,它就会自动填充您当前的登录凭据并自动填充 slug 名称。将 slug 更改为您想要的任何内容,然后单击导入。
You get an email when the import finishes and there is a progress bar on the page if you want to sit and wait.
导入完成后,您会收到一封电子邮件,如果您想坐等,页面上会显示一个进度条。
I'd also like to note that I can post an answer but can't comment on Parkar's answer because I don't have 50 reputation.
我还想指出,我可以发布答案,但不能评论 Parkar 的答案,因为我没有 50 声望。
EDIT: Just in case you're new enough that you can't find the repository URL, you can get the URL from going to the repository, hitting the Clonebutton and copying just the URL portion of the clone command it pops up with. You may also need to change the selection drop down from SSH to HTTPS for the authorization to work automatically.
编辑:以防万一您不够新而无法找到存储库 URL,您可以从存储库获取 URL,点击“克隆”按钮并仅复制它弹出的克隆命令的 URL 部分。您可能还需要将选择下拉列表从 SSH 更改为 HTTPS,以便授权自动工作。