I have a bare git repository connected to a Subversion repository (I used git svn clone
and manually made the git repository a bare one with the steps at the end of my post), but when I try to commit to Subversion I get
$ git svn dcommit
fatal: this operation must be run in a work tree
update-index --refresh: command returned error: 128
Using git option --work-tree
does not help:
$ git --work-tree="path-to-working-copy" svn dcommit
fatal: not a git repository: '.'
rev-parse --symbolic --all: command returned error: 128
Adding option --no-rebase
also didn't help.
Notes:
- "path-to-working-copy" points to a git clone of the bare git repository mentioned above. Why this is so, see background information below.
git svn rebase
too does not work:
$ git svn rebase
fatal: this operation must be run in a work tree
update-index --refresh: command returned error: 128
But this is not a problem because I can use git svn fetch --parent
instead. The only problem I have is that I cannot commit from the bare repository to Subversion.
Background information for those who are curious why I need a bare git clone of a Subversion repository:
I'm working on a lot of projects using Subversion but I want to improve my git skills working locally with git, especially pulling and pushing from a git repository. So instead of directly working with a local Git repository created with git svn clone
I want to work like this:
- Create a Git clone, let's name it "GitSvnClone" of the Subversion repository with
git svn clone
- Create a Git clone of "GitSvnClone" with
git clone
, let's name it "PureGitClone" - I do all my development work in "PureGitClone" and push/pull changes to/from "GitSvnClone" like in a regular pure Git environment.
- I use git-svn on "GitSvnClone" to synchronise my work with the other developers that are using Subversion.
This is a bit extra work for me but it's worth the effort to get more familiar with git push/pull commands. For a few projects this works really well BUT the repository "GitSvnClone" also has a work tree. I now want to get rid of this work tree for 2 reasons:
- It uses disk space: for every project I have two work trees on my disk. The projects are many and the work trees big and I do not have enough disk space to extend my "git training method" to all projects I'm working on.
- After a
git push
from "PureGitClone" to "GitSvnClone" the work tree in in "GitSvnClone" is modified so I have to do agit reset --hard
before everygit svn dcommit
.
I figured out how to make "GitSvnClone" a bare repository with the help of How to convert a normal Git repository to a bare one? and I connected repository "PureGitSvn" with the new bare version of "GitSvnClone" with git remote set-url origin <URL to my NEW bare repo location>
, see How to migrate GIT repository from one server to a new one