0

I have got a shared project with a number of submodules. Usually, when I want to update my working branch I execute next commands:

> git pull origin my_branch_name

and after that update my submodules:

> git submodule update --init --recursive

it updates all my submodules and initializes new one, if someone adds them to the project.

Problem is the project has got a lot of submodules, and some of them I don't use at all, but they require a lot of space on HDD. Is it possible to delete locally unused submodules and forbid git downloads them, when I update all submodules together?

Malov Vladimir
  • 490
  • 4
  • 11
  • 1
    Check this thread and its answer https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule – kosist Oct 06 '18 at 12:28

1 Answers1

1

Don't delete them, just don't bother fetching them. That's part of the value of submodules, you don't have to fetch or check out anything you don't need.

git submodule update --init --recursive is the the command to fetch every submodule in sight and then repeat until no more can be found. That's not what you want, so don't do it.

Make a list of what needs doing and record that in a script. That's what scripts are for, to record common command sequences. history|awk '$2~/git|cd/' can be useful, do whatever exploration you need and then hunt through your history to collect your paydirt. You want to end up with a sequence of cd's and git submodule updates that does what you want, you'd have to make that list anyway, might as well keep it in a form the shell can use to redo it on command.

jthill
  • 55,082
  • 5
  • 77
  • 137