2

I need help with git. I have a server, username and parol. I connect with ssh succesfully but i cannot add files. When i want add files (from my local pc) with bash using git add it returing cannot find file path or path doesnot exist. I think it's searching files or directory in the server.

Thanks.

Dmitry Egorov
  • 9,542
  • 3
  • 22
  • 40

1 Answers1

1

With Git you don't create a repository directly on a server. Instead, you

  • create a repository locally (git init),
  • add files to it, which generally comprises two steps:
    • stage files (git add)
    • commit the staged files into the local repository (git commit)
  • assign a remote server's repository to it (git remote add)
    • Note 1: I assume you have created a remote repository somehow - please refer to your server instructions.
    • Note 2: You create an empty repository on the server.
  • upload your local repository to the remote one (git push)

Sample script:

$ cd your_local_project_dir/              # Get into your your project directory

$ git init                                # Initialize a local repository

$ git add --all                           # Stage all files from your local project
                                          # directory for commit (note this is not
                                          # adding to the repository yet, it's just
                                          # "prepare them to add into the repo")

$ git commit -m "Initial commit"          # Add the staged files to the local repository

$ git remote add origin https://server.com/user/project_name.git
                                          # Link the local repository to a remote one

$ git push -u origin master               # Upload you local repository data to the
                                          # remote one
Dmitry Egorov
  • 9,542
  • 3
  • 22
  • 40
  • Thanks for answer. I have done until add origin. I dont how i can do this. I have just ip adress server and username - parol for ssh connection. – Samir Agcayev May 15 '18 at 07:28
  • @SamirAgcayev, you need to create an empty repository on that server. Is it a public server? – Dmitry Egorov May 15 '18 at 07:29
  • Then you have to establish an SSH session with that server and run three commands from [this post](https://stackoverflow.com/a/5136451/4295017). Apparently, you've got to use your paths. – Dmitry Egorov May 15 '18 at 07:34