Selivanov Pavel
Selivanov Pavel

Reputation: 360

Make git pull --recurse-submodules update submodule to latest commit on submodule branch

I want git pull --recurse-submodules to update all submodules to the latest commit on their branch.

.gitmodules:

[submodule "roles-shared"]
    path = roles-shared
    url = ../../project/roles-shared.git
    branch=master

I update master branch in roles-shared repository, adding 1 new commit.

I do git pull --recurse-submodules in main repository:

Fetching submodule roles-shared
From gitlab:project/roles-shared
   83de1f4..f0688dd  master     -> origin/master
Already up to date.

Submodule got all new commits, but it not updated, it is 1 commit behind master:

# submodule foreach git status

Entering 'roles-shared'
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Is there any way to make git pull automatically update submodules to their latest commits?

Upvotes: 1

Views: 5330

Answers (1)

Aaron Walerstein
Aaron Walerstein

Reputation: 854

git pull && git submodule foreach git pull origin master

Upvotes: 3

Related Questions