How do I add a remote Git repository to an Ubuntu Server?

后端 未结 7 650
孤街浪徒
孤街浪徒 2021-01-30 03:52

I have created a Git repository on my Desktop machine (Windows 7) with:

git init
git add 
git commit -m \"added my files\"

相关标签:
7条回答
  • 2021-01-30 04:29

    you need a colon:

    git remote add origin jonas@192.168.1.10/home/jonas/code/myproject.git
    

    should be:

    git remote add origin jonas@192.168.1.10:/home/jonas/code/myproject.git
    
    0 讨论(0)
  • 2021-01-30 04:37

    Did you setup the repository on the remote server? You need to run

    mkdir -p /home/jonas/code/myproject.git
    cd /home/jonas/code/myproject.git
    git init --bare
    

    on the server in order to set it up. I recommend taking a look at how to setup a git server in the free ProGit book.

    0 讨论(0)
  • 2021-01-30 04:38

    I normally create a bare repository locally and then scp that repository to the server when I'm setting up a remote repository.

    For example,

    cd c:\gits
    git clone --bare c:\path\to\local\repository\some_project
    

    which creates some_project.git.

    Then,

    scp -r some_project.git login@some.server:/path/to/remote/gits/.
    

    enter your password or maybe you already have public/private key access working.

    0 讨论(0)
  • 2021-01-30 04:40

    First thing I notice is that you're missing a ':'. Should be git remote add origin jonas@192.168.1.10:/home/jonas/code/myproject.git

    0 讨论(0)
  • 2021-01-30 04:44
    git remote add origin jonas@192.168.1.10/home/jonas/code/myproject.git
    

    When using SSH, remote repository addresses can be expressed in two ways. One using absolute paths and one using relative paths from the users home directory. You've mixed them up.

    The corrected command would be one of the following.

    git remote add origin jonas@192.168.1.10:code/myproject.git
    git remote add origin ssh://jonas@192.168.1.10/home/jonas/code/myproject.git
    
    0 讨论(0)
  • Connecting your Local Repo. to Git Remote Server Ubuntu

    Create a User in remote server and assign permission for ssh access using ssh-keygen in your local server and paste, its .pub file to ssh of the remote server.

    Things to do on remote Server

    Server : XX.XXX.1XX.XX

    Inside Putty command line

    1. Go to location : cd ~/srv/git srv in your root directory

    2. Make a folder : mkdir your_file_name followed by cd inside your file inside your git folder

    3. initialize git there : git init --bare

         Done
      

    Things to do On Local Machine

    1. create your repository ..

    2. initializing Git: git init

    3. Create the remote connection : git remote add origin git@xx.xxx.xxx.xxx:/srv/git/your_file_name

    4. git push.

          Done
      

    If you got stuck any point refer :https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server.

    0 讨论(0)
提交回复
热议问题