can't push a new repo

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

What I did:

  • Unable to clone directly into a git tag using -b <tagname>
  • how to install coq contribs using git?
  • Checkout branch from Github without cloning whole repo, and without Git
  • Splitting each commit by file?
  • Git how to rename a folder/package remotely?
  • How to undo 'git add' before commit?
  • 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


    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?

    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

  • Pushing files on github
  • How do you create a remote Git branch?
  • How do I make unpushable commits pushable?
  • Bash in Git for Windows: Weirdness when running a command with CMD.exe /C with args
  • Stuck in a git commit loop
  • Picking the commits to merge with master
  • 2 Solutions collect form web for “can't push a new repo”

    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"

    You need to create a bare git repo on the server so that the client git repo has somewhere to push to.

    From your example, the add remote tells the client where to push its repo changes to, and expects there to be a repo on the server that matches the added remote.

    Git Baby is a git and github fan, let's start git clone.