barrywardell / git-module

A tool for simplifying the management of git submodules
GNU Lesser General Public License v2.1
2 stars 0 forks source link

Provide support for checking out multiple branches at once #9

Open hoppese opened 11 years ago

hoppese commented 11 years ago

I have several branches to different submodules, mostly with minor local changes. Ideally, when I run 'git-module update', something like this would happen:

Perhaps a .branches file could exist in the root of the suer-repository. It could have one section for each submodule, and the name of the branch to be checked out. This would allow the user to quickly see the default list of branches that are used in each submodule. Further, a command like, 'git-module checkout trunk' could checkout trunk on each submodule, and then 'git-module checkout default' would return all the submodules to whatever is listed in the .branches file.

ianhinder commented 11 years ago

NB: there is already a "revision" entry in .gitmodules which associates a branch to each submodule. I'm not sure exactly what this does.

barrywardell commented 11 years ago

The "revision" entry keeps track of which branch should be checked out for each submodule. When you run 'git-module update' what happens currently within each submodule is:

  1. Run 'git fetch' to get the new commits.
  2. Run 'git checkout' to checkout the commit in the "revision" entry in .gitmodules.
  3. Run 'git pull'.

I have wondered if this would be better with some other name, such as 'git-module pull'.

For what you want, I think you should edit .gitmodules and put in the branches that you actually want to use, run 'git-module update' and then run a merge. There is currently no git-module command for this, but it can probably be achieved using something like 'git submodule foreach "git merge origin"'.

hoppese commented 11 years ago

Thanks a lot Barry. This is very close to what I was looking for. Here is the current situation. For concreteness, consider the submodule CTGamma. I have a local branch called psiclopsMod. It has a few minor changes, unlikely to conflict with other development taking place on the master branch. We have configured the upstream for psiclopsMod to point to origin/master. Now, if I run 'git pull' inside the CTGamma repository, it pulls and merges the recent changes from origin/master to psiClopsMod. On the other hand, if I edit the 'revision' entry in the .gitmodules file, and then run git-module update, this doesn't work. The reason appears to be that git-module is by default safe and will only perform fast-forward merges. So, what would be great is an option for git-module to force the merge. Perhaps this could be another field in .gitmodules, so you could choose whether to force the merge on a submodule basis?

ianhinder commented 11 years ago

The choices when "pulling" a submodule would be "ff-only", "merge" and "rebase". This could be a setting "pull-type" or just "pull" in .gitmodules for each submodule, and would refer to the branch specified in "revision". The default if left unspecified would be "ff-only".

This could also be configured in the submodule repositories themselves. See http://www.kernel.org/pub/software/scm/git/docs/git-config.html, specifically the options branch.autosetupmerge, branchautosetuprebase, branch..mergeoptions, branch..rebase.

We should probably come up with some use cases and work out the best set of options to provide to accommodate them.

ianhinder commented 11 years ago

I have added a wiki page for more detailed notes: https://github.com/barrywardell/git-module/wiki/Updating