Name Null
Name Null

Reputation: 461

Visual studio code cannot handle Git with GIT_DIR and GIT_WORK_TREE in separate folders

Context(can be skipped):

In many scenarios I wish to version control my files on iCloud drive, like my ledgers, notes, or diaries.

However If I just initialize a .git folder in my iCloud folder, chances are that the syncing breaks down and files become partially synced. It seems that the .git folder fooled the iCloud syncing mechanism mysteriously. (And why?)

I tried to put .git folder on my local disk drive, and use GIT_WORK_TREE environment variable to make git manage folders on my iCloud drive and it succeeded in the terminal. git diff works just fine.

Ways to reproduce the setup about this problem:

  1. create a folder on local path ~/GitTest
  2. cd ~/GitTest; git init
  3. edit ~/GitTest/.git/config and adds work-tree = /Users/someone/Library/Mobile Documents/com~apple~CloudDocs/GitTest
  4. open vscode on ~/GitTest or /Users/someone/Library/Mobile Documents/com~apple~CloudDocs/GitTest, and nothing happens. The VCS plugin does not recognize anything.
  5. touch /Users/someone/Library/Mobile Documents/com~apple~CloudDocs/GitTest/a.txt; cd ~/GitTest; git add /Users/someone/Library/Mobile Documents/com~apple~CloudDocs/GitTest/a.txt
  6. git status: it shows that the file is already staged for commit, meaning the git command line tool does recognize it.

However, GUI Git management tools like Visual Studio Code or IntelliJ IDEA cannot recognize the .git folder.

It seems that these modern Git management tools never expected that a user would put .git folder and GIT_WORK_TREE in separate locations?

Upvotes: 0

Views: 40

Answers (0)

Related Questions