0

I have a git repo in /srv/git/mysite.git.

Workdir is set to

/srv/www/mysite

in git /srv/git/mysite.git/config:

[core] repositoryformatversion = 0
filemode = false
bare = false
worktree = /srv/www/mysite

[receive] denyCurrentBranch = updateInstead

I would like to split with subtree the directory content at:

/srv/www/mysite/mysubsite

to branch mysubsite.

When I execute:

cd /srv/git/mysite.git
git subtree split --prefix=mysubsite -b mysubsite

I get error

You need to run this command from the toplevel of the working tree.

It seems this thread has related info about my problem: http://git.661346.n2.nabble.com/git-users-Problem-using-detached-worktrees-with-commands-implemented-in-scripts-td7597786.html

I tried the following:

export GIT_WORK_TREE=/srv/www/mysite

export GIT_DIR=/srv/git/mysite.git

cd /srv/www/mysite

git subtree split --prefix=mysubsite -b mysubsite

I get error again:

You need to run this command from the toplevel of the working tree.

How can I fix this?

0

Finally I got help in another forum: https://stackoverflow.com/a/60467173/4523359

The solution was to use the --git-dir option in work-tree path:

$ cd /srv/www/mysite
$ git --git-dir=/srv/git/mysite.git subtree split --prefix=mysubsite -b mysubsite

Using this solution, the branch was created successfully!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.