Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Linux上通过ssh向git repo添加/克隆项目_Linux_Git_Ssh_Clone_Commit - Fatal编程技术网

在Linux上通过ssh向git repo添加/克隆项目

在Linux上通过ssh向git repo添加/克隆项目,linux,git,ssh,clone,commit,Linux,Git,Ssh,Clone,Commit,在本地,我用我的某个文件创建了一个回购协议。然后我想通过ssh(在Linux上)将这个repo(这个文件)添加到其他服务器上的repo中。所以在我的本地机器上: mkdir localRepo && cd /localRepo git init touch someFile git add . git commit -m "add someFile" git remote add origin ssh://smith@sam.uf.com/srv/git/hello.git 为

在本地,我用我的某个文件创建了一个回购协议。然后我想通过ssh(在Linux上)将这个repo(这个文件)添加到其他服务器上的repo中。所以在我的本地机器上:

mkdir localRepo && cd /localRepo
git init
touch someFile
git add .
git commit -m "add someFile"
git remote add origin ssh://smith@sam.uf.com/srv/git/hello.git
为了检查在本地机器上是否一切正常,我已经创建了一个新的repo并从其他机器上克隆:

cd .. && mkdir localRepo2 && cd localRepo2
git init
git clone ssh://smith@sam.uf.com/srv/git/hello.git
在本地计算机上“localRepo2”中的repo中没有文件“someFile”,但应该是。我做错了什么

git remote add origin ssh://smith@sam.uf.com/srv/git/hello.git
仅在本地repo中添加对远程的引用。它不会推送/获取任何文件

您应该从
localRepo
将文件推送到远程repo

git push origin master
然后,要从另一个本地回购获得它,您可以立即克隆一个新的本地回购,或者转到
localRepo2
并执行以下操作

git pull origin master

添加遥控器后,是否可以按