Search code examples
gitgithubgit-submodulesgit-add

undo submodule and make it a directory to a github repository


I cloned a repository from github, and I would like to make it a directory in an other github repository. Though it is considered as a submodule (and I don't want it to be a submodule, but a directory). In this directory i have some script that I would like to push on my github repository.

When i do : git status i get this error message:

On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   my_directory (untracked content)

no changes added to commit (use "git add" and/or "git commit -a")

I tried to do git add . ; git add my_directory and to commit it, but it's not working neither.

I don't find any .gitignore or .gitmodules...

edit :

finally i find how to do what i want, i had to delete the .git that was in my directory. Though it was an invisible file... Once this was done, i just had to do git commit -a and then git push


Solution

  • If that directory has a .git/ subfolder in it, it will act as a nested git repository.

    If you add that folder, you actually are adding only the tree SHA1 (gitlink) to your repo, not the folder content.

    To undo that:

    git rm --cached my_directory
    

    (very important: no trailing slash: you want to delete the entry, not the folder content)

    If you don't care about the history of the content, delete my_directory/.git

    Then you can add, commit and push as usual: that folder will be a regular folder.