Wednesday, February 5, 2020

git submodule



*** sync submodule
$ git checkout master
M meta-openembedded
M poky
$ git submodule update

git submodule add https://git.kernel.org/pub/scm/linux/kernel src/linux

git config examples)
.git/config
[submodule "linux"]
url = https://git.kernel.org/pub/scm/linux/kernel

.gitmodules
[submodule "linux-msm"]
path = src/linux
url = https://git.kernel.org/pub/scm/linux/kernel
rev = b27efee486f8a24682f36908fb2693a7b310303b

git clone --recurse-submodules --branch <branch name> <git url>

git clone --single-branch --recurse-submodules --branch <branch name> <git url>

git submodule sync
    Synchronizing submodule url for 'xxx'
    fatal: no submodule mapping found in .gitmodules for path 'yyy'
git rm -r yyy --cached

trouble shootings)
git rm --cached src/linux
rm -rf src/linux
rm -rf .git/modules/src/linux



git submodule [--quiet] add [-b branch] [-f|--force]
      [--reference <repository>] [--] <repository> [<path>]
git submodule [--quiet] status [--cached] [--recursive] [--] [<path>…​]
git submodule [--quiet] init [--] [<path>…​]
git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase]
      [--reference <repository>] [--merge] [--recursive] [--] [<path>…​]
git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>…​]
git submodule [--quiet] foreach [--recursive] <command>
git submodule [--quiet] sync [--] [<path>…​]


*** Update git submodule to their remote origin

# Get the submodule initially
git submodule add ssh://bla submodule_dir
git submodule init

# Time passes, submodule upstream is updated
# and you now want to update

# Change to the submodule directory
cd submodule_dir

# Checkout desired branch
git checkout master

# Update
git pull

# Get back to your project root
cd ..

# Now the submodules are in the state you want, so
git commit -am "Pulled down update to submodule_dir"


git submodule foreach git pull origin master





No comments:

Post a Comment