0

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:

  1. "path-to-working-copy" points to a git clone of the bare git repository mentioned above. Why this is so, see background information below.
  2. 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:

  1. Create a Git clone, let's name it "GitSvnClone" of the Subversion repository with git svn clone
  2. Create a Git clone of "GitSvnClone" with git clone, let's name it "PureGitClone"
  3. I do all my development work in "PureGitClone" and push/pull changes to/from "GitSvnClone" like in a regular pure Git environment.
  4. 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:

  1. 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.
  2. After a git push from "PureGitClone" to "GitSvnClone" the work tree in in "GitSvnClone" is modified so I have to do a git reset --hard before every git 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

user -27
  • 33
  • 5
  • Here is a similar problem: https://superuser.com/questions/1131632/can-an-svn-repository-be-cloned-as-a-git-bare-repository-with-a-simple-command – user -27 Feb 18 '22 at 21:29
  • 1
    I don't think this mode is supported. (I have not actually *used* git-svn for anything though.) Just spend the disk space; it's cheap. (Admittedly fast SSDs might be expensive for a while, but a 2TB USB drive is under $100.) – torek Feb 19 '22 at 09:27
  • Thanks, torek. I now also think that this mode is not supported, see my answer below. – user -27 Feb 19 '22 at 17:59

1 Answers1

0

Answering my own question:

I'm pretty sure that my constellation described in my question with a Subversion repository, Git repository "GitSvnClone" and Git repository "PureGitClone" can not work if "GitSvnClone" is a bare repository or does not have a work tree inside it's directory for the following reasons:

  1. Doing a git svn fetch in bare repository "GitSvnClone" fetches from SVN but the fetched commits are on the remote branch. The problem now is that it is not possible to integrate these commits from the remote branch into my local branch (at least using porcelain commands only) see for example Poke's answer here

  2. Even if I mark the repository "GitSvnClone" as not bare I found no way that git svn dcommit commits to Subversion:

$ git --git-dir="path-to-GitSvnClone" work-tree="path-to-PureSvnClone" svn dcommit --no-rebase
bareSvnTest/changedFile1.txt: needs update
update-index --refresh: command returned error: 1
user -27
  • 33
  • 5