Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't push a new repo

Tags:

git

ssh

I am confused while creating a new git repository and pushing it to a ssh based git server.

What I did:

mkdir knowledge_base
cd knowledge_base
git init

( create some files )

git add <some files>
git commit -m 'initial'

until here all is perfect

now a do:

git remote add origin ssh://gitzfrdh@ex/home/gitzfrdh/gitrepos/knowledge_base
git push --set-upstream origin master

error:

fatal: '/home/gitzfrdh/gitrepos/knowledge_base' does not appear to be a git repository fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Yes, I know that the repo did not exist. My idea is to push this new one.

Must I first create a bare repo on the server side?

EDIT: If I execute on the server:

mkdir knowledge_base
cd knowledge_base/
git init --bare

and on the client again a:

git push --set-upstream origin master

all works.

But I think it is not the intention to have a full excess on the server? I am wrong?

I already read Pushing new files in a new repository Git New git repository error on first push

like image 384
Klaus Avatar asked Nov 08 '22 13:11

Klaus


1 Answers

The command is correct; however, the remote address must point to an initialized Git repository too. It's a one-time job, though

ssh user@host "git init --bare /your/project/git/my-project.git"
like image 84
Ankanna Avatar answered Nov 15 '22 06:11

Ankanna