سؤال

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:

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:

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?

هل كانت مفيدة؟

المحلول

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

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

git pull origin master
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top