简体   繁体   English

如何从我的服务器获取 Git repo url 并从本地开发人员直接推送到它。 终端?

[英]How to get Git repo url from my server and push directly to it from local dev. terminal?

I have cloned my private repo from Github to my server via SSH including SSH keys.我已经通过 SSH 将我的私人仓库从 Github 克隆到我的服务器,包括 SSH 密钥。 From my development terminal, I use origin to push to the repo on Github.从我的开发终端,我使用 origin 推送到 Github 上的仓库。 From my server (logged in via Putty) I pull my master branch.从我的服务器(通过 Putty 登录)我拉出我的主分支。

I was wondering if it is possible to directly push my master branch from local development terminal to my server, I was thinking I just need my URL like the GitHub URL user@github..../repo (origin), etc.我想知道是否可以将我的主分支从本地开发终端直接推送到我的服务器,我想我只需要我的 URL 就像 GitHub URL 用户....

Is this possible and if so, how to determine the right URL?这可能吗?如果可以,如何确定正确的 URL? I get stuck on command (of course it returns Github)我被命令卡住了(当然它返回 Github)

git config --get remote.origin.url

Are you planning to ignore the phase of pushing to Github?您是否打算忽略推送到 Github 的阶段? If so then no, you have to push first to Github or any git server then only you can pull somewhere else.如果是这样,那么不,您必须先推送到 Github 或任何 git 服务器,然后只有您可以拉到其他地方。

Also, As you said the SSH keys are only added to the server, you need to add your local terminal too to push from local machine to Github.另外,正如您所说,SSH 密钥仅添加到服务器,您还需要添加本地终端才能从本地计算机推送到 Github。

There is no place to get the URL from.没有地方可以得到 URL。 You need to construct it.你需要构建它。

As you can connect to the server with PuTTY you have SSH access.由于您可以使用 PuTTY 连接到服务器,因此您具有 SSH 访问权限。 So use SSH URL.所以使用 SSH URL。 Combine host, port, username (say, "ole") and the full path to the remote directory at the server.结合主机、端口、用户名(比如“ole”)和服务器上远程目录的完整路径。

Run pwd at the server to get the full path, it will be something like /home/ole/project .在服务器上运行pwd以获取完整路径,它将类似于/home/ole/project To verify the URL first run ssh host ls /home/ole/project .要验证 URL 首先运行ssh host ls /home/ole/project When it works construct the URL: ssh://ole@server_host/home/ole/project and try it with git clone .当它工作时,构建 URL: ssh://ole@server_host/home/ole/project并尝试使用git clone

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

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