ingydotnet / git-subrepo

MIT License
3.24k stars 268 forks source link

What is a missing but already registered worktree? #584

Closed jcalfee closed 1 year ago

jcalfee commented 1 year ago

I'm getting a strange error:

$ git-subrepo push my-folder
git-subrepo: Command failed: 'git worktree add .git/tmp/subrepo/my-folder subrepo/my-folder'.
fatal: '.git/tmp/subrepo/my-folder' is a missing but already registered worktree;
use 'add -f' to override, or 'prune' or 'remove' to clear
Preparing worktree (checking out 'subrepo/my-folder')

This is my last commit message in this repository:

    git subrepo init --remote=ssh://git@mydomain.org/sys/my-folder.git my-folder

    subrepo:
      subdir:   "my-folder"
      merged:   "4fbb5c2"
    upstream:
      origin:   "ssh://git@mydomain.org/sys/my-folder.git"
      branch:   "master"
      commit:   "none"
    git-subrepo:
      version:  "0.4.5"
      origin:   "https://github.com/ingydotnet/git-subrepo"
      commit:   "dbb99be"

The command I used hoping to convert the existent comited folder into a subrepo:

git subrepo init my-folder -r ssh://git@mydomain.org:2224/sys/my-folder.git --method rebase
admorgan commented 1 year ago

I am not able to reproduce your error locally. Is there the potential that I could look at the current state of this repo to debug what is happening? In the end you are likely to have to run git subrepo clean my-folder and try again*

jcalfee commented 1 year ago

Sorry, have not made that public let. Thanks for getting back to me. I can go in a loop: clean, error, clean, error. Clean just works but the push is there. Maybe it has something to do with rebase. I also have a nested subrepo in my-folder too, that one is working fine.

$ git-subrepo push my-folder
The "git rebase" command failed:

You will need to finish the push by hand. A new working tree has been
created at .git/tmp/subrepo/my-folder so that you can resolve the conflicts
shown in the output above.

This is the common conflict resolution workflow:

  1. cd .git/tmp/subrepo/my-folder
  2. Resolve the conflicts (see "git status").
  3. "git add" the resolved files.
  4. git rebase --continue
  5. If there are more conflicts, restart at step 2.
  6. cd /home/james/dev/inpower/inpower
  7. git subrepo push my-folder subrepo/my-folder
See "git help rebase" for details.

Alternatively, you can abort the push and reset back to where you started:

  1. git subrepo clean my-folder

See "git help subrepo" for more help.
jcalfee commented 1 year ago

Also, It seams there is nothing to do to fix the rebase.

.git/tmp/subrepo/my-folder$ git status .
On branch subrepo/my-folder
nothing to commit, working tree clean
admorgan commented 1 year ago

I believe I know the issue. You can't rebase on an empty repo. Could you try creating an initial commit on the target repo and see what happens?

jcalfee commented 1 year ago

Thanks! I think that was it but I'm not sure. I added a remote file then discovered I was pointed to master and gitlab defaults to main so I did a subrepo config to change then committed this:

 [subrepo]
        remote = ssh://git@mydomain.org/sys/my-folder.git
-       branch = master
+       branch = main
        commit = 
        method = rebase
        cmdver = 0.4.5

Then I was able to subrepo pull and push. Thank you!