Search code examples
gitversion-controlrepositorygit-push

GIT pushing a new project for the first time


I have a project on my local machine I've been working on alone, that I'd like to push to a remote server (running ubuntu & gitosis)

On the remote server I did

git init
Initialized empty Git repository in /home/stefan/.git/

Locally git status says

git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .DS_Store
#   .travis.yml
#   license.txt
#   nbproject/
#   bla/.DS_Store
#   bla/cache/
nothing added to commit but untracked files present (use "git add" to track)

I have also done

git remote add origin dev@123.456.xx.xxx:psdemo.git

Now: when I try to push, the following happens

git push origin master
fatal: 'psdemo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

It makes sense in a way since I just have an empty git repo.

How can I push my files to this remote server? I guess what I need is cloning from my local machine to the remote machine, somehow?


Solution

  • The string

    dev@123.456.xx.xxx:psdemo.git
    

    should be a valid ssh path. As far as I see in the previous line:

    git init
    Initialized empty Git repository in /home/stefan/.git/
    

    You created a repository in /home/stefan/ so I would expect something like:

    stefan@123.456.xx.xxx:~
    

    But probably it isn't what you want. You should create a folder psdemo.git in your home in the remote server. For this, do a

    git init --bare ~/psdemo.git
    

    In that and then add the remote with:

     stefan@123.456.xx.xxx:~/psdemo.git
    

    Then you should be able to push!