Git submodule 命令

更新时间: 2019-07-13 17:17

git-submodule - Initialize, update or inspect submodules

语法

git submodule [--quiet] add [<options>] [--] <repository> [<path>]
git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
git submodule [--quiet] init [--] [<path>...]
git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>...)
git submodule [--quiet] update [<options>] [--] [<path>...]
git submodule [--quiet] summary [<options>] [--] [<path>...]
git submodule [--quiet] foreach [--recursive] <command>
git submodule [--quiet] sync [--recursive] [--] [<path>...]
git submodule [--quiet] absorbgitdirs [--] [<path>...]

参数

-q, --quiet
    Only print error messages.

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

-b, --branch
    Branch of repository to add as submodule. The name of the branch is recorded as submodule.<name>.branch in .gitmodules for update
    --remote. A special value of .  is used to indicate that the name of the branch in the submodule should be the same name as the
    current branch in the current repository.

-f, --force
    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.

--cached
    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.

--files
    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.

-n, --summary-limit
    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.

--remote
    This option is only valid for the update command. Instead of using the superproject's recorded SHA-1 to update the submodule, use
    the status of the submodule's remote-tracking branch. The remote used is branch's remote (branch.<name>.remote), defaulting to
    origin. The remote branch used defaults to master, but the branch name may be overridden by setting the submodule.<name>.branch
    option in either .gitmodules or .git/config (with .git/config taking precedence).

    This works for any of the supported update procedures (--checkout, --rebase, etc.). The only change is the source of the target
    SHA-1. For example, submodule update --remote --merge will merge upstream submodule changes into the submodules, while submodule
    update --merge will merge superproject gitlink changes into the submodules.

    In order to ensure a current tracking branch state, update --remote fetches the submodule's remote repository before calculating
    the SHA-1. If you don't want to fetch, you should use submodule update --remote --no-fetch.

    Use this option to integrate changes from the upstream subproject with your submodule's current HEAD. Alternatively, you can run
    git pull from the submodule, which is equivalent except for the remote branch name: update --remote uses the default upstream
    repository and submodule.<name>.branch, while git pull uses the submodule's branch.<name>.merge. Prefer submodule.<name>.branch if
    you want to distribute the default upstream branch with the superproject and branch.<name>.merge if you want a more native feel
    while working in the submodule itself.

-N, --no-fetch
    This option is only valid for the update command. Don't fetch new objects from the remote site.

--checkout
    This option is only valid for the update command. Checkout the commit recorded in the superproject on a detached HEAD in the
    submodule. This is the default behavior, the main use of this option is to override submodule.$name.update when set to a value
    other than checkout. If the key submodule.$name.update is either not explicitly set or set to checkout, this option is implicit.

--merge
    This option is only valid for the update command. Merge the commit recorded in the superproject into the current branch of the
    submodule. If this option is given, the submodule's HEAD will not be detached. If a merge failure prevents this process, you will
    have to resolve the resulting conflicts within the submodule with the usual conflict resolution tools. If the key
    submodule.$name.update is set to merge, this option is implicit.

--rebase
    This option is only valid for the update command. Rebase the current branch onto the commit recorded in the superproject. If this
    option is given, the submodule's HEAD will not be detached. If a merge failure prevents this process, you will have to resolve
    these failures with git-rebase(1). If the key submodule.$name.update is set to rebase, this option is implicit.

--init
    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.

--name
    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 /.

--name
    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 /.

--reference <repository>
    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.

    NOTE: Do not use this option unless you have read the note for git-clone(1)'s --reference and --shared options carefully.

--recursive
    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).

--depth
    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)

--[no-]recommend-shallow
    This option is only valid for the update command. The initial clone of a submodule will use the recommended
    submodule.<name>.shallow as provided by the .gitmodules file by default. To ignore the suggestions use --no-recommend-shallow.

-j <n>, --jobs <n>
    This option is only valid for the update command. Clone new submodules in parallel with as many jobs. Defaults to the
    submodule.fetchJobs option.

<path>...
    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).

查看更多 git submodule 命令的使用方法,可以使用命令:

git help submodule
The Everything Store

The Everything Store

Brad Stone / Little, Brown and Company / 2013-10-22 / USD 28.00

The definitive story of Amazon.com, one of the most successful companies in the world, and of its driven, brilliant founder, Jeff Bezos. Amazon.com started off delivering books through the mail. Bu......一起来看看 《The Everything Store》 这本书的介绍吧!

HTML 编码/解码

HTML 编码/解码

HTML 编码/解码

URL 编码/解码

URL 编码/解码

URL 编码/解码

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具