Locally I have created a repo with my some file. Then I would like to add this repo (this file) to the repo which is on other server by ssh (on Linux). So on my local machine:
在本地我用我的文件创建了一个repo。然后我想将这个repo(这个文件)添加到ssh(在Linux上)在其他服务器上的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
To check if everyhing go well on local machine I have created a new repo and clone from other machine:
要检查在本地计算机上是否正常运行,我已经创建了一个新的repo并从其他计算机克隆:
cd .. && mkdir localRepo2 && cd localRepo2
git init
git clone ssh://smith@sam.uf.com/srv/git/hello.git
In the repo in "localRepo2" on local machine there is no file "someFile", but it should be. What I have done wrong?
在本地机器上的“localRepo2”中的repo中没有文件“someFile”,但它应该是。我做错了什么?
1 个解决方案
#1
1
git remote add origin ssh://smith@sam.uf.com/srv/git/hello.git
only adds a reference to the remote in your local repo. It doesn't push / get any file.
只在本地仓库中添加对遥控器的引用。它不会推送/获取任何文件。
From your localRepo
you should push your file to your remote repo
从localRepo,您应该将文件推送到远程仓库
git push origin master
Then to get it from another local repo you could either clone a new local repo now, or go to the localRepo2
and do
然后从另一个本地仓库获取它你可以现在克隆一个新的本地仓库,或者转到localRepo2并做
git pull origin master
#1
1
git remote add origin ssh://smith@sam.uf.com/srv/git/hello.git
only adds a reference to the remote in your local repo. It doesn't push / get any file.
只在本地仓库中添加对遥控器的引用。它不会推送/获取任何文件。
From your localRepo
you should push your file to your remote repo
从localRepo,您应该将文件推送到远程仓库
git push origin master
Then to get it from another local repo you could either clone a new local repo now, or go to the localRepo2
and do
然后从另一个本地仓库获取它你可以现在克隆一个新的本地仓库,或者转到localRepo2并做
git pull origin master