Git/Bonobo - 将本地存储库添加到远程

Git/Bonobo - Add local repository to remote

我刚刚开始使用 Git 在本地网络上进行版本控制。为了允许多个用户同步存储库,我还开始使用运行良好的 Bonobo Git 服务器包。

到目前为止,我总是通过在 Bonobo 中创建它来初始化存储库,将其克隆到本地目录,添加文件等,然后根据需要推/拉。

现在假设我最初在本地目录中创建存储库,使用它一段时间然后想将它添加到远程服务器,保持所有提交历史完整无缺。

我该怎么做?是否有与 git 克隆相反的方法 - 即获取现有的本地存储库并将其添加到远程服务器?

您必须在服务器上创建一个空存储库。 (确保它是 空的! 有些服务器会要求您使用 README 或 .gitignore 或其他东西进行初始化 - 您不需要那样做。)一旦你这样做了,得到url 并将其添加为 remote:

git remote add origin http://url-to-remote.git

然后做一个push:

git push origin master -u

这假设您正在推动 master 分支。 -u 指定您的 master 应该 "track" 服务器上的 master

自 Bonobo Git 服务器版本 6.0.0 起,您可以 auto-create 推送存储库。该设置必须首先由管理员用户启用(默认情况下关闭)并且 auto-create-on-push 不能来自匿名用户。

git remote add Bonobo http://<your-username>@url-to-remote.git
git push Bonobo master

遗憾的是,ChangeLog 没有提供太多见解。如果一开始这不起作用,请查看 Bonobo 的 AppData/Logs 文件夹中的错误日志。

分步说明:

  1. 创建您的文件夹mkdir myFolder
  2. 输入你的文件夹cd myFolder
  3. 启动 git 回购 git init
  4. 创建文件或想要的文件夹内容type nul > someFile.txt
  5. 向存储库添加更改 git add *
  6. 提交更改git commit -m "intial setup"
  7. 添加远程git remote add origin http://<your-username>@url-to-remote.git
  8. 远程推送git push origin master

我只是将整个存储库文件夹复制到 Bonobo 的存储库文件夹,然后单击 Bonobo 管理存储库页面中的 "Rescan directory" 选项。它选择了新的存储库作为自己的存储库。可能是在最近的版本中添加了重新扫描目录选项。

我可以通过先将其添加到我的 Bonobo 网站来添加它。然后我转到团队资源管理器-> 存储库设置并从站点添加 link。之后,我单击 visual studio window 右下角的 master 分支并选择推送。 master push to bonobo.git