繁体   English   中英

如何正确地将本地存储库上的远程设置为我在服务器上的集中存储库?

[英]How correctly set the remote on a local repository to my centralized repository on a server?

我按照本教程在 Linux 服务器上创建了一个中央存储库:

http://rypress.com/tutorials/git/centralized-workflows

所以基本上我实际上有这个文件夹:

MyServer@MyUser:~/repositories/backend-central-repo.git$

在代表我的远程 GIT 存储库的服务器上。

我使用以下地址通过SSH连接到此服务器: MyServer.cloudapp.net 、用户名MyUser和相关密码。

现在在我的本地机器上,我有一个本地 GIT 存储库,例如:

Andrea@Andrea-PC MINGW64 ~/Documents/TESTREPO (master)

在这个存储库中,我提交了一个test.txt文件,事实上我有这个提交:

$ git log
commit a11633549763c4cc905a721932c4c6bdc1a1091c
Author: AndreaNobili <nobili.andrea@gmail.com>
Date:   Tue Oct 4 20:17:35 2016 +0200

    test

然后,在我的本地存储库中,我将远程存储库添加为原点,执行以下操作:

$ git remote add origin MyServer.cloudapp.net/repositories/backend-central-re
po.git$

然后我尝试做:

Andrea@Andrea-PC MINGW64 ~/Documents/TESTREPO (master)
$ git remote -v
origin  MyServer.cloudapp.net/repositories/backend-central-repo.git$ (fetch)
origin  MyServer.cloudapp.net/repositories/backend-central-repo.git$ (push)

这是什么意思? 它工作正常吗?

“似乎不是 git 存储库

你的 repo 的 ssh url 应该是

MyUser@MyServer.cloudapp.net:/home/MyUser/repositories/backend-central-repo.git

在您的本地仓库中尝试:

git remote set-url origin MyUser@MyServer.cloudapp.net:/home/MyUser/repositories/backend-central-repo.git

然后,如果您的远程仓库为空,您可以将本地仓库推送到它:

git push -u origin master

暂无
暂无

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

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