Bitbucket submodules wont delete

2019-06-09 16:25发布

问题:

I accidentally pushed a couple folders to bitbucket that had .git folders in them because I cloned them using git clone.

I can't click these folders or go into them in bitbucket

what do I do to get rid of those I already used:

rm -rf .git 

for those two .git folders then:

git reset --hard ^HEAD
git push
git commit -a -m "Message"
git push

I also have tried setting the commit back one but that didn't work either. there are no submodule files for these I've also moved the folders from there directory and made another push yet they still apear.

回答1:

Those are not "folders with .git" you see on the bitbucket site.

Those are submodules.

And removing the .git and pushing won't change that, since:

  • the .gitmodules of your main repo still does declare said submodules
  • the index still contain a special entry (gitlink, mode 160000)

To remove a submodule, see "How do I remove a Git submodule?" (git 1.8.5+):

git submodule deinit asubmodule    
git rm asubmodule
# Note: asubmodule (no trailing slash)
# or, if you want to leave it in your working tree
git rm --cached asubmodule

Then commit and push.



标签: git bitbucket