简体   繁体   中英

How to set GIT_WORK_TREE with git-bash

I have a static site inside the directory SITE, which I want to git-push to a github repo. I'm using windows and git-bash. I'm in the static1 directory:

$ls -la

drwxr-xr-x 1 me 1049089   0 Oct 21 15:35 ./
drwxr-xr-x 1 me 1049089   0 Oct 20 18:11 ../
drwxr-xr-x 1 me 1049089   0 Oct 21 15:35 .git/
drwxr-xr-x 1 me 1049089   0 Oct 21 15:36 .idea/
-rw-r--r-- 1 me 1049089 245 Nov  6 13:01 README.txt
drwxr-xr-x 1 me 1049089   0 Nov  6 12:37 SITE/

I want to configure the GIT_WORK_TREE to point to SITE.

Following https://www.git-scm.com/docs/git-config/1.7.8

I tried:

$ git config --local --work-tree="mypath\static1\SITE"

when I check:

$ vim .git/config

I see:

    [core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true

ie no changes . How can I set GIT_WORK_TREE at the repo level?

You can use core.worktree but you must use an absolute path.

git config core.worktree /full/path/to/SITE

It might be easier to use $PWD to do this:

cd SITE
git config core.worktree $PWD

Note that if you screw this up, you may have to delete the worktree entry from .git/config manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM