git-extras icon indicating copy to clipboard operation
git-extras copied to clipboard

How to update a submodule version to latest ?

Open manobi opened this issue 13 years ago • 20 comments

I always have to do this, there are a better way ?

manobi avatar Feb 15 '12 23:02 manobi

You should actually just update with normal git methods like it's a standalone repo and then add the repo and commit:

cd submodule_name
git checkout master && git pull
cd ..
git add submodule_name
git commit -m "updating submodule to latest"

paularmstrong avatar Feb 16 '12 00:02 paularmstrong

yeah I just git pull as well. we could probably do with something like this but I dont get the name at all, readd? what is that?

tj avatar Feb 16 '12 22:02 tj

readd === re add || remove && add

Good thing to automate, but I don't know a better name for it. Suggestions ?

manobi avatar Feb 16 '12 22:02 manobi

oh I see. but yeah we should change how it's done anyway, typically like @paularmstrong mentioned you just cd in git pull origin master and cd ..

tj avatar Feb 16 '12 23:02 tj

update-submodules would be a more obvious, albeit verbose, command.

There's also a git submodule foreach method that you should consider wrapping this in so that all of a project submodules get updated.

paularmstrong avatar Feb 17 '12 04:02 paularmstrong

update-submodule is easy to confuse with traditional git submodule update. Another suggestion ?

manobi avatar Feb 19 '12 00:02 manobi

+1 nice idea.

Currently doing the usual:- git submodule foreach git pull origin master

gaving avatar Jan 16 '13 17:01 gaving

The other way to update submodule which tracks branch is:

git pull --recurse-submodules
git submodule update --remote --recursive

kshcherban avatar Feb 04 '15 09:02 kshcherban

Sorry for missing this!

@manobi Still interested to complete this?

If not any of you guys want to paw at it?

hemanth avatar Feb 04 '15 09:02 hemanth

@kshcherban the best way, thanks! I also like to use --merge instead of --recursive, it persist current branch in submodule.

FelikZ avatar Jun 10 '15 12:06 FelikZ

@spacewander Looks like we must bring in this?

hemanth avatar Jun 10 '15 16:06 hemanth

So, what name should we use for it?

update-submodule or merge-submodule or others?

spacewander avatar Jun 11 '15 11:06 spacewander

pull-submodule?

FelikZ avatar Jun 11 '15 12:06 FelikZ

merge-submodule sound good if fetch and merge we could name it pull-submodule?

hemanth avatar Jun 11 '15 16:06 hemanth

Ok, so name it as pull-submodule. I will try to dive into it this weekend.

spacewander avatar Jun 11 '15 16:06 spacewander

:+1:

hemanth avatar Jun 11 '15 16:06 hemanth

pull-submodule?

kornvigo avatar Jul 28 '17 15:07 kornvigo

The following command will update all submodules to the latest branch that's defined in .gitmodules...

git submodule update --recursive --remote
[submodule "my/module"]
	path = my/module
	branch = master

RobLoach avatar Jan 21 '19 19:01 RobLoach

git submodule foreach git pull origin master

MarceloMelo1 avatar Apr 04 '19 20:04 MarceloMelo1

git submodule update --remote

DreamAndDead avatar Aug 28 '20 02:08 DreamAndDead