Search code examples
gitgithubgit-submodules

How can I delete git submodule wreckage?


While pushing my code history to git repository, I found that Objective-C project work as a submodule, which means if I push Objective-C project, it work as a submodule, like this.

After I notice that factor, I tried to reinitialize my .git folder. (delete and tried to call 'git init')

But it would not work at all and submodules are still alive.

I also tried git submodule deinit and init command. However, after that, even though I tried to push my files to git repository, it throw out this message.

Sogos-Macbook:Test code dkswogus7530$ git push -u origin master

To https://github.com/JaehyunAhn/cpuls2_book_review.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/JaehyunAhn/cpuls2_book_review.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I also tried to update & delete my git repository to type command git pull origin master and that command abort this message

Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 537 bytes | 0 bytes/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: error: object d5c202897cf6f769235a2707d15719636fe37984:contains duplicate file entries
remote: fatal: Error in object
error: unpack failed: index-pack abnormal exit
To https://github.com/JaehyunAhn/cpuls2_book_review.git
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'https://github.com/JaehyunAhn/cpuls2_book_review.git'

How can I resolve this problem?

This submodule repository pointed from this, this and this.


Solution

  • If all else fails and you really just want to start again why not cd into the repo and each submodule and then:

    rm -rd .git