git clone through ssh

后端 未结 10 2110
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 08:47

I have a project on which I created a git repository:

$ cd myproject  
$ git init  
$ git add .  
$ git commit  

I the wanted to create a b

相关标签:
10条回答
  • 2020-12-12 09:06

    For repositories on GitHub, try:

    git clone ssh://git@github.com/<user>/<repository name>.git
    

    For setting up git to clone via ssh see:

    • Generating SSH Keys and add your generated key in Account Settings -> SSH Keys

    • Cloning with SSH

    0 讨论(0)
  • 2020-12-12 09:12

    Upfront, I am a bit lacking in my GIT skills.

    That is going to clone a bare repository on your machine, which only contains the folders within .git which is a hidden directory. execute ls -al and you should see .git or cd .git inside your repository.

    Can you add a description of your intent so that someone with more GIT skills can help? What is it you really want to do not how you plan on doing it?

    0 讨论(0)
  • 2020-12-12 09:12

    git clone git@server:Example/proyect.git

    0 讨论(0)
  • 2020-12-12 09:14

    Git 101:

    git is a decentralized version control system. You do not necessary need a server to get up and running with git. Still you might want to do that as it looks cool, right? (It's also useful if you want to work on a single project from multiple computers.)

    So to get a "server" running you need to run git init --bare <your_project>.git as this will create an empty repository, which you can then import on your machines without having to muck around in config files in your .git dir.

    After this you could clone the repo on your clients as it is supposed to work, but I found that some clients (namely git-gui) will fail to clone a repo that is completely empty. To work around this you need to run cd <your_project>.git && touch <some_random_file> && git add <some_random_file> && git commit && git push origin master. (Note that you might need to configure your username and email for that machine's git if you hadn't done so in the past. The actual commands to run will be in the error message you get so I'll just omit them.)

    So at this point you can clone the repository to any machine simply by running git clone <user>@<server>:<relative_path><your_project>.git. (As others have pointed out you might need to prefix it with ssh:// if you use the absolute path.) This assumes that you can already log in from your client to the server. (You'll also get bonus points for setting up a config file and keys for ssh, if you intend to push a lot of stuff to the remote server.)

    Some relevant links:
    This pretty much tells you what you need to know.
    And this is for those who know the basic workings of git but sometimes forget the exact syntax.

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