git clone from local to remote

前端 未结 6 2055
慢半拍i
慢半拍i 2020-12-23 12:03

We\'re in the process of migrating from Mercurial to Git for our workflow and I have two minor issues.

First, is it possible to \"clone\" a local repository directly

6条回答
  •  甜味超标
    2020-12-23 12:24

    I also ran into this issue recently and solved it as follows:

    On remote server:

    1: Create a directory named /tmp/bare
    2: Change to that directory
    3: Execute git init --bare

    On local machine:

    1: Change to your git project directory
    2: git remote add bare ssh://user@server/tmp/bare
    3: git push --all bare
    4: git remote remove bare

    On remote server:

    1: git clone /tmp/bare /path/to/your/clone

    On local machine:

    1: git remote add origin ssh://user@server/path/to/your/clone

    This is a little involved, but it works and does not require setting any weird flags or instructing git to override its default behaviours. It is hence quite safe.

提交回复
热议问题