首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GIT:如何在WHM服务器上创建git存储库并与SourceTree连接

问GIT:如何在WHM服务器上创建git存储库并与SourceTree连接
EN

Stack Overflow用户
提问于 2016-04-14 00:18:47
回答 1查看 757关注 0票数 0

我需要在我的cPanel WHM上设置一个git服务器,生成一个连接到repo的URL (我已经在/opt/ Git /repo.git上创建了一个repo,并配置了SourceTree或任何其他windows visual Git客户端。

我遵循了这个指南:https://newagesoldier.com/setting-git-cpanel-server/和安装我的回购。

然后,我试图通过在windows控制台上运行以下命令来克隆它:

代码语言:javascript
复制
git clone git@server.domain.com/opt/git/repository.git

但是得到了这个错误:

致命:存储库'URL‘不存在

我读过很多关于这个案子的帖子和问题,但很多都是老的,其他的要么不清楚,要么不完整。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2016-08-28 12:47:08

如何在windows和cpanel linux帐户之间使用ssh进行git推拉.

*服务器: Linux: centos/whm/cpanel/ssh帐户

开发: Windows7 x64: with C:/cygwin (2016),putty (2015年),

代码语言:javascript
复制
[Windows]
> puttygen
  generate and save to ~/.ssh/myprivatekey.ppk
    > save as openssh > myopenssh.key
    > Copy public key mypublickey.txt

[Cpanel]
  Allow ssh access
  Paste mypublickey.txt into cpanel ssh keys,
    Authorize key.

[Check SSH key works]
> ssh -V
  ..2016..
> c:/cygwin/bin/rsync --list-only \
    -e "ssh -i myopenssh.key" \
    "USERNAME@website.org:/home/USERNAME"
  SUCCESS

[Linux]
> putty USERNAME@website.org
  using above myprivatekey.ppk
$ pwd
  /home/USERNAME
$ hostname
  website.org
# Setup git repo on linux
$ git --version  # 1.7... yum update...on linux if you need a new git.    
$ alias git="/usr/local/cpanel/3rdparty/bin/git"    
$ git --version # 2.8...        
$ mkdir ~/repo.git ; cd ~/repo.git ; git init --bare    
  Initialized empty Git repository in /home/USERNAME/repo.git/
$ git config --global user.name "USERNAME"
$ git config --global user.email USERNAME@website.org
$ cd ~ ; git init; git remote add repo repo.git     
$ git add public_html
$ git commit -m "first commit"
$ git push repo master
   SUCCESS

[Windows]
:: **Now clone CPANEL account into xampp**
> cd c:/xampp/htdocs/WEBSITE
> git --version # 2.8...
> git init
> git remote add origin ssh://USERNAME@website.org/home/USERNAME/repo.git
> git pull
  Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
> git config core.sshCommand "ssh -i path/to/openssh.key" 
:: Dont use doublequotes in the next command
> set GIT_SSH_COMMAND=ssh -i path/to/myopenssh.key   
> git pull
  SUCCESS 
:: .. edit .. commit 
> git push
  SUCCESS

windows/cmd/cygwin的可选设置

代码语言:javascript
复制
> set HOME=c:/users/%USERNAME%
> setx HOME %HOME% -m
> cd /d %HOME%
> mkdir .ssh
:: OR create a hardlink to your .ssh dir
> mklink /D c:/your/.ssh .ssh
> ls -al ~/.ssh/

如果windows cygwin64 64/ssh抱怨~/ . ssh/config的权限不好,请使用此标志-F。

代码语言:javascript
复制
> set  GIT_SSH_COMMAND=ssh -F ~/.ssh/config -i path/to/myopenssh.key   
> setx GIT_SSH_COMMAND "ssh -F ~/.ssh/config -i path/to/myopenssh.key" -m
> ssh -F ~/.ssh/config -i path/to/myopenssh.key  
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36611713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档