Adding Git Remote to Different Directory

后端 未结 2 669
走了就别回头了
走了就别回头了 2021-01-13 18:57

So I am writing a script that initializes a git repository in ~/.cfi, adds a remote, and pulls it down from the server.

Creating the directory, and init

2条回答
  •  暖寄归人
    2021-01-13 19:27

    Yes, with the --git-dir and --work-tree options.

    And since git 1.8.5, you even can use -C (shorter option).
    See "Use git log command in another folder"

    git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo remote add xxx
    git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo pull
    

    Or:

    git -C /path/to/repo remote add xxx
    git -C /path/to/repo pull
    

提交回复
热议问题