How to delete submodule git

How to delete submodule git

How to delete submodule git

Check your version of git by running

SYNOPSIS

DESCRIPTION

A submodule is a repository embedded inside another repository. The submodule has its own history; the repository it is embedded in is called a superproject.

The gitlink entry contains the object name of the commit that the superproject expects the submodule’s working directory to be at.

Submodules can be used for at least two different use cases:

Using another project while maintaining independent history. Submodules allow you to contain the working tree of another project within your own working tree while keeping the history of both projects separate. Also, since submodules are fixed to an arbitrary version, the other project can be independently developed without affecting the superproject, allowing the superproject project to fix itself to new versions only when desired.

Splitting a (logically single) project into multiple repositories and tying them back together. This can be used to overcome current limitations of Git’s implementation to have finer grained access:

Size of the Git repository: In its current form Git scales up poorly for large repositories containing content that is not compressed by delta computation between trees. For example, you can use submodules to hold large binary assets and these repositories can be shallowly cloned such that you do not have a large history locally.

Transfer size: In its current form Git requires the whole working tree present. It does not allow partial trees to be transferred in fetch or clone. If the project you work on consists of multiple repositories tied together as submodules in a superproject, you can avoid fetching the working trees of the repositories you are not interested in.

Access control: By restricting user access to submodules, this can be used to implement read/write policies for different users.

The configuration of submodules

Submodule operations can be configured using the following mechanisms (from highest to lowest precedence):

If the submodule is not yet initialized, then the configuration inside the submodule does not exist yet, so where to obtain the submodule from is configured here for example.

This file mainly serves as the mapping between the name and path of submodules in the superproject, such that the submodule’s Git directory can be located.

If the submodule has never been initialized, this is the only place where submodule configuration is found. It serves as the last fallback to specify where to obtain the submodule from.

FORMS

Submodules can take the following forms:

It is possible to construct these old form repositories manually.

How to delete submodule git

Check your version of git by running

SYNOPSIS

DESCRIPTION

A submodule is a repository embedded inside another repository. The submodule has its own history; the repository it is embedded in is called a superproject.

The gitlink entry contains the object name of the commit that the superproject expects the submodule’s working directory to be at.

Submodules can be used for at least two different use cases:

Using another project while maintaining independent history. Submodules allow you to contain the working tree of another project within your own working tree while keeping the history of both projects separate. Also, since submodules are fixed to an arbitrary version, the other project can be independently developed without affecting the superproject, allowing the superproject project to fix itself to new versions only when desired.

Splitting a (logically single) project into multiple repositories and tying them back together. This can be used to overcome current limitations of Git’s implementation to have finer grained access:

Size of the Git repository: In its current form Git scales up poorly for large repositories containing content that is not compressed by delta computation between trees. For example, you can use submodules to hold large binary assets and these repositories can be shallowly cloned such that you do not have a large history locally.

Transfer size: In its current form Git requires the whole working tree present. It does not allow partial trees to be transferred in fetch or clone. If the project you work on consists of multiple repositories tied together as submodules in a superproject, you can avoid fetching the working trees of the repositories you are not interested in.

Access control: By restricting user access to submodules, this can be used to implement read/write policies for different users.

The configuration of submodules

Submodule operations can be configured using the following mechanisms (from highest to lowest precedence):

If the submodule is not yet initialized, then the configuration inside the submodule does not exist yet, so where to obtain the submodule from is configured here for example.

This file mainly serves as the mapping between the name and path of submodules in the superproject, such that the submodule’s Git directory can be located.

If the submodule has never been initialized, this is the only place where submodule configuration is found. It serves as the last fallback to specify where to obtain the submodule from.

FORMS

Submodules can take the following forms:

It is possible to construct these old form repositories manually.

How to delete submodule git

Check your version of git by running

SYNOPSIS

DESCRIPTION

A submodule is a repository embedded inside another repository. The submodule has its own history; the repository it is embedded in is called a superproject.

The gitlink entry contains the object name of the commit that the superproject expects the submodule’s working directory to be at.

Submodules can be used for at least two different use cases:

Using another project while maintaining independent history. Submodules allow you to contain the working tree of another project within your own working tree while keeping the history of both projects separate. Also, since submodules are fixed to an arbitrary version, the other project can be independently developed without affecting the superproject, allowing the superproject project to fix itself to new versions only when desired.

Splitting a (logically single) project into multiple repositories and tying them back together. This can be used to overcome current limitations of Git’s implementation to have finer grained access:

Size of the Git repository: In its current form Git scales up poorly for large repositories containing content that is not compressed by delta computation between trees. For example, you can use submodules to hold large binary assets and these repositories can be shallowly cloned such that you do not have a large history locally.

Transfer size: In its current form Git requires the whole working tree present. It does not allow partial trees to be transferred in fetch or clone. If the project you work on consists of multiple repositories tied together as submodules in a superproject, you can avoid fetching the working trees of the repositories you are not interested in.

Access control: By restricting user access to submodules, this can be used to implement read/write policies for different users.

The configuration of submodules

Submodule operations can be configured using the following mechanisms (from highest to lowest precedence):

If the submodule is not yet initialized, then the configuration inside the submodule does not exist yet, so where to obtain the submodule from is configured here for example.

This file mainly serves as the mapping between the name and path of submodules in the superproject, such that the submodule’s Git directory can be located.

If the submodule has never been initialized, this is the only place where submodule configuration is found. It serves as the last fallback to specify where to obtain the submodule from.

FORMS

Submodules can take the following forms:

It is possible to construct these old form repositories manually.

How to delete submodule git

Check your version of git by running

SYNOPSIS

DESCRIPTION

Inspects, updates and manages submodules.

A submodule allows you to keep another Git repository in a subdirectory of your repository. The other repository has its own history, which does not interfere with the history of the current repository. This can be used to have external dependencies such as third party libraries for example.

When cloning or pulling a repository containing submodules however, these will not be checked out by default; the init and update subcommands will maintain submodules checked out and at appropriate revision in your working tree.

Submodules are not to be confused with remotes, which are other repositories of the same project; submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project. If you want to merge the project histories and want to treat the aggregated whole as a single project from then on, you may want to add a remote for the other project and use the subtree merge strategy, instead of treating the other project as a submodule. Directories that come from both projects can be cloned and checked out as a whole if you choose to go that route.

COMMANDS

Add the given repository as a submodule at the given path to the changeset to be committed next to the current project: the current project is termed the «superproject».

is the relative location for the cloned submodule to exist in the superproject. If

is not given, the «humanish» part of the source repository is used («repo» for «/path/to/repo.git» and «foo» for «host.xz:foo/.git»). The

is the relative location for the cloned submodule to exist in the superproject. If

does not exist, then the submodule is created by cloning from the named URL. If

does exist and is already a valid Git repository, then this is added to the changeset without cloning. This second form is provided to ease creating a new submodule from scratch, and presumes the user will later push the submodule to the given URL.

If you are only interested in changes of the currently initialized submodules with respect to the commit recorded in the index or the HEAD, git-status[1] and git-diff[1] will provide that information too (and can also report changes to a submodule’s work tree).

When the command is run without pathspec, it errors out, instead of deinit-ing everything, to prevent mistakes.

OPTIONS

Only print error messages.

This option is only valid for the deinit command. Unregister all submodules in the working tree.

This option is only valid for add, deinit and update commands. When running add, allow adding an otherwise ignored submodule path. When running deinit the submodule working trees will be removed even if they contain local changes. When running update (only effective with the checkout procedure), throw away local changes in submodules when switching to a different commit; and always run a checkout operation in the submodule, even if the commit listed in the index of the containing repository matches the commit checked out in the submodule.

This option is only valid for status and summary commands. These commands typically use the commit found in the submodule HEAD, but with this option, the commit stored in the index is used instead.

This option is only valid for the summary command. This command compares the commit in the index with that in the submodule HEAD when this option is used.

This option is only valid for the summary command. Limit the summary size (number of commits shown in total). Giving 0 will disable the summary; a negative number means unlimited (the default). This limit only applies to modified submodules. The size is always limited to 1 for added/deleted/typechanged submodules.

This option is only valid for the update command. Don’t fetch new objects from the remote site.

This option is only valid for the update command. Initialize all submodules for which «git submodule init» has not been called so far before updating.

This option is only valid for the add command. It sets the submodule’s name to the given string instead of defaulting to its path. The name must be valid as a directory name and may not end with a /.

This option is only valid for add and update commands. These commands sometimes need to clone a remote repository. In this case, this option will be passed to the git-clone[1] command.

This option is only valid for foreach, update, status and sync commands. Traverse submodules recursively. The operation is performed not only in the submodules of the current repo, but also in any nested submodules inside those submodules (and so on).

This option is valid for add and update commands. Create a shallow clone with a history truncated to the specified number of revisions. See git-clone[1]

This option is only valid for the update command. Clone new submodules in parallel with as many jobs. Defaults to the submodule.fetchJobs option.

Paths to submodule(s). When specified this will restrict the command to only operate on the submodules found at the specified paths. (This argument is required with add).

Core Concept, Workflows And Tips

How to delete submodule git. Смотреть фото How to delete submodule git. Смотреть картинку How to delete submodule git. Картинка про How to delete submodule git. Фото How to delete submodule git

Nicola Paolucci

Table Of Contents

Core Concept

First, let me provide a brief explanation on a core concept about submodules that will make them easier to work with.

Submodules are tracked by the exact commit specified in the parent project, not a branch, a ref, or any other symbolic reference.

They are never automatically updated when the repository specified by the submodule is updated, only when the parent project itself is updated. As very clearly expressed in the Pro Git chapter mentioned earlier:

When you make changes and commit in that [submodule] subdirectory, the superproject notices that the HEAD there has changed and records the exact commit you’re currently working off of; that way, when others clone this project, they can re-create the environment exactly.

Possible Workflows

By remembering this core concept and reflecting on it, you can understand that submodule support some workflows well and less optimally others. There are at least three scenarios where submodules are a fair choice:

When a component or subproject is changing too fast or upcoming changes will break the API, you can lock the code to a specific commit for your own safety.

When you have a component that isn’t updated very often and you want to track it as a vendor dependency. I do this for my vim plugins for example.

When you are delegating a piece of the project to a third party and you want to integrate their work at a specific time or release. Again this works when updates are not too frequent.

Credit to finch for the well-explained scenarios.

Useful Tips Incoming

The submodule infrastructure is powerful and allows for useful separation and integration of codebases. There are however simple operations that do not have a streamlined procedure or strong command line user interface support.

If you use git submodules in your project you either have run into these or you will. When that happens you will have to look the solution up. Again and again. Let me save you research time: Instapaper, Evernote or old school bookmark this page (:D:D) and you will be set for a while.

So, here is what I have for you:

How to swap a git submodule with your own fork

This is a very common workflow: you start using someone else’s project as submodule but then after a while you find the need to customize it and tweak it yourself, so you want to fork the project and replace the submodule with your own fork. How is that done?

You can just edit the url with a text editor and then run the following:

How do I remove a submodule?

It is a fairly common need but has a slightly convoluted procedure. To remove a submodule you need to:

Commit and delete the now untracked submodule files.

How do I integrate a submodule back into my project?

Or, in other words, how do I un-submodule a git submodule? If all you want is to put your submodule code into the main repository, you just need to remove the submodule and re-add the files into the main repo:

Delete the reference to the submodule from the index, but keep the files:

Add the submodule to the main repository index:

NOTE: The procedure outlined above is destructive for the history of the submodule, in cases where you want to retain a congruent history of your submodules you have to work through a fancy «merge». For more details I defer you to this very complete Stack Overflow reference.

How to ignore changes in submodules

Danger Zone! Pitfalls Interacting with Remotes

As the Git Submodule Tutorial on kernel.org reminds us there are a few important things to note when interacting with your remote repositories.

The first is to always publish the submodule change before publishing the change to the superproject that references it. This is critical as it may hamper others from cloning the repository.

The second is to always remember to commit all your changes before running git submodule update as if there are changes they will be overwritten!

Conclusions

Follow me @durdn and the awesome @Bitbucket team for more DVCS rocking.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *