Git repository with git directory stored elsewhere

后端 未结 5 879
栀梦
栀梦 2020-12-31 17:48

I\'m sorry if this is a duplicate, I\'ve searched google and SO and couldn\'t find anything similar since it\'s a fairly generic set of words to search for!

What I w

5条回答
  •  别那么骄傲
    2020-12-31 18:27

    I'm not really sure if this is a good advice, but you can set the GIT_DIR environment variable to point to a non-bare git directory. Beware that in this setup git is not able to find the top work directory, so you must be sure to be in the correct directory when you issuing git commands.

    mkdir foobar
    cd foobar
    git init
    export GIT_DIR=$PWD/.git
    cd ..
    mkdir wc
    cd wc
    echo foo > bar.txt
    git add .
    git commit
    

提交回复
热议问题