ingydotnet / git-subrepo

MIT License
3.24k stars 268 forks source link

Not a valid object name when push dot named subrepo #583

Open xiaoyao9184 opened 1 year ago

xiaoyao9184 commented 1 year ago

I used a directory name with a dot '.', which usually can't be used in a branch name, I tried using git subrepo init and it worked, but when I did a git subrepo push it failed, guessing because of the dot name , the same git repo branch also fails.

git-subrepo: Command failed: 'git branch subrepo/%2eseed '.
fatal: Not a valid object name: ''.
git-subrepo Version: 0.4.5
Copyright 2013-2020 Ingy döt Net
https://github.com/ingydotnet/git-subrepo
/home/xy/git-subrepo/lib/git-subrepo
Git Version: 2.30.2
artem-sidorenko commented 1 year ago

I have the same issue using git subrepo pull. When I execute the git branch command directly - it works just fine

artem-sidorenko commented 1 year ago

it looks like it should be resolved by PR https://github.com/ingydotnet/git-subrepo/pull/498

xiaoyao9184 commented 1 year ago

After re-init and clone, I found that it was actually because the rebase changed the commit id and the .gitrepo file not same.

jcalfee commented 1 year ago

Work around? I rebased the master branch and I can push one subrepo, but 3 other nested subrepo's under that one all fail with this error. All subrepos are in rebase mode.

related: https://github.com/ingydotnet/git-subrepo/issues/503#issuecomment-1595365110

tennox commented 9 months ago

Workaround

  1. commit all changes
  2. create a branch: git checkout -b subrepo-fix
  3. delete subrepo: rm -rf subrepo/
  4. re-clone: git subrepo clone git@gitlab.com:org/subrepo.git subrepo/
  5. Check for differences in repo state: git diff main (optimally, only subrepo/.gitrepo is different)

If you had changes in the parent repo that are not reset to subrepo state

Reset the files to the state on the main branch: git checkout main -- subrepo/file.txt (be sure not to reset .gitrepo)

Example: my MR

taktran commented 5 months ago

I found a potential fix for this issue here: https://github.com/ingydotnet/git-subrepo/issues/617