Samir Agcayev
Samir Agcayev

Reputation: 21

GIT SSH Connection to server and create repository there and add files

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.

Upvotes: 2

Views: 1563

Answers (1)

Dmitry Egorov
Dmitry Egorov

Reputation: 9650

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

Upvotes: 1

Related Questions