Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git submodule absolute worktree path config

This is my submodule redmine_dashboard config file:

Submodule config file:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    worktree = /Users/daniel/redmine/vendor/plugins/redmine_dashboard
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:ebc/redmine_dashboard.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[gui]
    wmstate = normal
    geometry = 841x391+-8+43 187 177

Mac

worktree = /Users/daniel/redmine/vendor/plugins/redmine_dashboard

Linux

worktree = /home/daniel/redmine/vendor/plugins/redmine_dashboard

Issue

Can I change this absolute path for a relative? Something like:

worktree = ../../vendor/plugins/redmine_dashboard
like image 394
flapjack Avatar asked Jan 19 '12 11:01

flapjack


People also ask

How do I add a submodule to a specific path?

In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.

What is path to submodule?

A submodule can be located anywhere in a parent Git repository's working directory and is configured via a . gitmodules file located at the root of the parent repository. This file contains which paths are submodules and what URL should be used when cloning and fetching for that submodule.

Where are git submodule hashes stored?

It is stored in Git's object database directly. The tree object for the directory where the submodule lives will have an entry for the submodule's commit (this is the so-called "gitlink").


2 Answers

Yes, you should be able to update the config file with a relative path. You should also update the worktree dir in the .git file in the submodule root to be a relative path back to that module.

I believe this is fixed in (at least) the most current version of git (1.7.10.1). I can't seem to find a changelog, so I have no idea when it got fixed. I was able to have git fix the issue by deleting both the submodule and the folder in the .git/modules folder and then redoing git submodule init and git submodule update.

like image 177
Andy Avatar answered Oct 04 '22 08:10

Andy


Note that the git config man page mentions:

core.worktree

Set the path to the root of the work tree. This can be overridden by the GIT_WORK_TREE environment variable and the --work-tree command line option.
It can be an absolute path or a relative path to the .git directory, either specified by --git-dir or GIT_DIR, or automatically discovered.
If --git-dir or GIT_DIR are specified but none of --work-tree, GIT_WORK_TREE and core.worktree is specified, the current working directory is regarded as the root of the work tree.

like image 35
VonC Avatar answered Oct 04 '22 08:10

VonC