简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM