【问题标题】:Git/Bonobo - Add local repository to remoteGit/Bonobo - 将本地存储库添加到远程
【发布时间】:2015-12-16 04:16:44
【问题描述】:
我刚刚开始在本地网络上使用 Git 进行版本控制。为了允许多个用户同步存储库,我还开始使用运行良好的 Bonobo Git Sever 包。
到目前为止,我一直通过在 Bonobo 中创建存储库来初始化存储库,将其克隆到本地目录,添加文件等,然后根据需要推送/拉取。
现在假设我最初在本地目录中创建存储库,使用它一段时间,然后想将其添加到远程服务器,保持所有提交历史不变。
我该怎么做?与 git clone 有什么相反的 - 即获取现有的本地存储库并将其添加到远程服务器?
【问题讨论】:
标签:
git
version-control
server
git-remote
bonobo
【解决方案2】:
从 Bonobo Git Server 6.0.0 版开始,您可以在推送时自动创建存储库。该设置必须首先由管理员用户启用(默认关闭)并且自动创建推送不能来自匿名用户。
git remote add Bonobo http://<your-username>@url-to-remote.git
git push Bonobo master
遗憾的是,ChangeLog 没有提供太多洞察力。如果一开始这不起作用,请查看 Bonobo 的 AppData/Logs 文件夹中的错误日志。
分步说明:
- 创建您的文件夹
mkdir myFolder
- 输入您的文件夹
cd myFolder
- 启动git repo
git init
- 创建文件或所需文件夹内容
type nul > someFile.txt
- 将更改添加到 repo
git add *
- 提交更改
git commit -m "intial setup"
- 添加远程
git remote add origin http://<your-username>@url-to-remote.git
- 远程推送
git push origin master
【解决方案3】:
我只是将整个存储库文件夹复制到 Bonobo 的存储库文件夹,然后单击 Bonobo 管理存储库页面中的“重新扫描目录”选项。它选择了新的存储库作为自己的存储库。可能是在最近的版本中添加了重新扫描目录选项。
【解决方案4】:
您必须在服务器上创建一个空存储库。 (确保它是空的! 一些服务器会要求您使用 README 或 .gitignore 或其他东西进行初始化 - 您不希望这样做。)一旦您这样做,获取 url 并将其添加为remote:
git remote add origin http://url-to-remote.git
然后做一个push:
git push origin master -u
这假设您正在推送master 分支。 -u 指定您的master 应该“跟踪”服务器上的master。