git clone through ssh

后端 未结 10 2135
爱一瞬间的悲伤
爱一瞬间的悲伤 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 08:57

    I want to attempt an answer that includes git-flow, and three 'points' or use-cases, the git central repository, the local development and the production machine. This is not well tested.

    I am giving incredibly specific commands. Instead of saying , I will say /root/git. The only place where I am changing the original command is replacing my specific server name with example.com. I will explain the folders purpose is so you can adjust it accordingly. Please let me know of any confusion and I will update the answer.

    The git version on the server is 1.7.1. The server is CentOS 6.3 (Final).

    The git version on the development machine is 1.8.1.1. This is Mac OS X 10.8.4.

    The central repository and the production machine are on the same machine.

    the central repository, which svn users can related to as 'server' is configured as follows. I have a folder /root/git where I keep all my git repositories. I want to create a git repository for a project I call 'flowers'.

    cd /root/git
    git clone --bare flowers flowers.git
    

    The git command gave two messages:

    Initialized empty Git repository in /root/git/flowers.git/
    warning: You appear to have cloned an empty repository.
    

    Nothing to worry about.

    On the development machine is configured as follows. I have a folder /home/kinjal/Sites where I put all my projects. I now want to get the central git repository.

    cd /home/kinjal/Sites
    git clone root@example.net:/root/git/flowers.git
    

    This gets me to a point where I can start adding stuff to it. I first set up git flow

    git flow init -d
    

    By default this is on branch develop. I add my code here, now. Then I need to commit to the central git repository.

    git add .
    git commit -am 'initial'
    git push
    

    At this point it pushed to the develop branch. I want to also add this to the master branch.

    git flow release start v0.0.0 develop
    git flow release finish v0.0.0
    git push
    

    Note that I did nothing between the release start and release finish. And when I did the release finish I was prompted to edit two files. This pushed the develop branch to master.

    On the production site, which is on the same machine as my central git repository, I want put the repository in /var/www/vhosts/example.net. I already have /var/www/vhosts.

    cd /var/www/vhosts
    git clone file:///root/git/flowers.git example.net
    

    If the production machine would also be on a different machine, the git clone command would look like the one used on the development machine.

提交回复
热议问题