What is the current way to remove the git submodule?

how from git version 1.9.3 (Apple Git -50) on mac, how to remove the git submodule? I read a lot of outdated information, many developers tell me that they will not work. What is the current way? will git deinit pathToSubModule do the trick?

The steps that I thought would work are here , but the comments say they won't.

Let me explain my current situation and what I need. I installed Quick repository and added it as a submodule to my project. This code has already been verified, while others use it. What I need to do now is to develop the same Quick repository and place it in the more secure github that my company has (so this is a completely different private github). After the fork, I want to add this fork as a gitSubmodule and let it replace the current Quick subodule that I installed earlier.

update: I read that the next correct solution in the latest version of git, please confirm?

 To remove a submodule added using: git submodule add blah@blah.com:repos/blah.git lib/blah Run: git rm lib/blah That it. For old versions of git (circa ~1.8.5) use: git submodule deinit lib/blah git rm lib/blah git config -f .gitmodules --remove-section submodule.lib/blah 
+62
git github git-submodules
Apr 24 '15 at 14:24
source share
2 answers

Do you have a git submodule deinit

 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> rm -rf .git/modules/<asubmodule> 



deinit

Unregister data of submodules, i.e. delete all submodule.$name
a section from .git/config along with its work tree.

Further calls to git submodule update , git submodule foreach and git submodule sync will skip any unregistered submodules until they are initialized again, so use this command if you do not want the submodule checked locally in your working tree.

If you really want to remove the submodule from the repository and commit it instead of git rm .

If --force specified, the submodule operation tree will be deleted even if it contains local modifications.

+120
Apr 24 '15 at 14:33
source share

How to safely remove a submodule.

(Adds to https://stackoverflow.com/a/3/5/ )

  • List and find the submodule section in the .gitmodules file. Tell via terminal vi .gitmodules . Example:

[submodule "submodules/afnetworking"] path = submodules/afnetworking url = https://github.com/CompanyName/afnetworking.git

  1. Submodules can be used with local forks. For long-term projects, the code may be different from the original repo and may have some fixes. It is a good idea to check if the submodule code has gone through changes during the project. Example. Look at the logs if they point to the master branch or some local branch. examining git logs to find the changes that were made through the terminal. they are usually stored in a directory, in my example, in a submodules directory. User$ cd submodules/afnetworking User$ git log

  2. Remove the submodule section from .gitmodules, save the file. Example: git status should only be displayed after changing modified: .gitmodules

  3. Build the changes with git add .gitmodules .

  4. List and find the submodule section in the .git/config files. Tell through the terminal vi .git/config . Example: [submodule "submodules/afnetworking"] url = https://github.com/CompanyName/afnetworking.git

  5. Delete the git cache sobmodule files. running git rm --cached submodules/afnetworking (without a slash) will delete it successfully. Example: User$ git rm --cached submodules/afnetworking rm 'submodules/afnetworking' <-- terminal output

  6. Delete the submodule files in the .git directory with rm -rf .git/modules/... Confirm this with git status after.

User$ rm -rf .git/modules/submodules/afnetworking/ User$ git status On branch feature/replace-afnetworking-submodule-with-pod Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: .gitmodules deleted: submodules/afnetworking Untracked files: (use "git add <file>..." to include in what will be committed) submodules/afnetworking/

  1. Commit the changes. Confirm with git status after.

User$ git commit -m "Remove submodule afnetworking" [feature/replace-afnetworking-submodule-with-pod 70e239222] Remove submodule afnetworking 2 files changed, 4 deletions(-) delete mode 160000 submodules/afnetworking User$ git status On branch feature/replace-afnetworking-submodule-with-pod Untracked files: (use "git add <file>..." to include in what will be committed) submodules/afnetworking/ nothing added to commit but untracked files present (use "git add" to track)

  1. Delete unused submodule files. User$ rm -rf submodules/afnetworking

  2. Remove links from an Xcode project. Build, fix compilation and execution.

0
Dec 12 '17 at 0:03
source share



All Articles