我该如何将Git仓库从Beanstalk迁移到Github?

8

我的代码仓库在 Beanstalk 上。我该如何将代码从 Beanstalk 移动到 Github

4个回答

16

非常棒的答案,同样也适用于另一种方式(从Github到Beanstalk)。 - nickspiel
1
这会复制提交历史记录吗?(以及所有分支?) - Muhammad Saleh

5

From the GitHub Documentation

# In this example, we use an external account named extuser and
# a GitHub account named ghuser to transfer repo.git

# Make a bare clone of the external repo to a local directory
$ git clone --bare https://githost.org/extuser/repo.git

# Push mirror to new GitHub repo
$ cd repo.git
$ git push --mirror https://github.com/ghuser/repo.git

# Remove temporary local repo
$ cd ..
$ rm -rf repo.git

2
如果您已经在Beanstalk上使用Git,那么您可以在GitHub上创建一个空仓库,然后将其添加为本地仓库的远程仓库。(假设您的仓库在~/project中)
cd ~/project
git remote add github <github-ssh-url-here>
git push github --all --tags

你也可以使用 push --all 命令,同时使用 push --tags 命令来推送标签。 - fge
1
我按照建议去做了,但是我没有得到分支。 - Thillai Narayanan

0
这里给出的其他答案对我没有用,但在Fork的Dan的帮助下(甚至向我展示了我根本不需要他的产品!),我得到了以下步骤,使得将我的9个repos从Beanstalk转移到githuhb变得非常容易。希望它们也能帮到其他人。
  1. 打开终端
  2. 在您的用户目录中创建一个临时目录:mkdir ~/moverepos
  3. 打开此目录:cd moverepos
  4. 克隆您的旧Beanstalk repo:git clone --bare <url/repositoryName.git>
  5. 打开包含repo的目录:cd repositoryName.git
  6. 打开Github,创建一个同名的新EMPTY repo并复制它的url。
  7. 将数据推送到新目标(我们的情况是GitHub):git push --mirror <newUrl/repositoryName.git>
  8. 如果这是您第一次执行此过程,则应提示您输入Beanstalk用户名和密码。现在输入它们并观察repo推送到github。
  9. 如果您完成了操作,可以在Finder中删除临时目录并停止操作。
  10. 如果您想移动更多的repos,请导航到“moverepos”的根目录:cd ..
  11. 回到步骤4。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接