From: Brando Miranda <brandojazz@gmail.com>
To: git@vger.kernel.org
Cc: Brando Miranda <brando9@stanford.edu>
Subject: feature request - can git submodule update pull/update the repos based on the .gitmodule file without additional flags?
Date: Tue, 3 Jan 2023 13:36:39 -0600 [thread overview]
Message-ID: <7F5A9722-527A-48C9-9A1C-8499FDDCF02A@gmail.com> (raw)
I find i have a git submodule file .gitmodule and when I go git submodule update, it ignores the stuff I wrote/have in my .gitmodule e.g. I have the exact branch I want to use. Why isn't the default behaviour of gitsubmodule to obey my .gitmodule file? It is very unintuitive. Then what is the .gitmodule file for?
More details:
- https://stackoverflow.com/questions/74988223/why-do-i-need-to-add-the-remote-to-gits-submodule-when-i-specify-the-branch
copy pasting contents of url:
Why do I need to add the `--remote` to git's submodule when I specify the branch in the .gitmodule file?
I want to pull/update the submodules at the right branch. Doing `git submodule update` pulls/updates the submodules but it changes to the wrong branch even when the branch I want to ALWAYS use is specified in the .gitsubmodule file.
Only when I do `--remote` does it work (but then I don't know what other unintended consequences it might have in the rest of my submodules).
I want to updat my modules **exactly** as specified in my .modules files. How do I do this?
e.g.
```
[submodule "pytorch-meta-dataset"]
path = pytorch-meta-dataset
url = git@github.com:brando90/pytorch-meta-dataset.git
branch = hdb
[submodule "meta-dataset"]
path = meta-dataset
url = git@github.com:brando90/meta-dataset.git
```
Is what I should be running:
```
git submodule update
git submodule update --remote
git submodule init
git submodule status
```
----
I did read the --remote:
```
--remote
This option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s
remote-tracking branch. The remote used is branch’s remote (branch.<name>.remote), defaulting to origin. The remote branch used defaults to the remote HEAD, but the branch
name may be overridden by setting the submodule.<name>.branch option in either .gitmodules or .git/config (with .git/config taking precedence).
This works for any of the supported update procedures (--checkout, --rebase, etc.). The only change is the source of the target SHA-1. For example, submodule update
--remote --merge will merge upstream submodule changes into the submodules, while submodule update --merge will merge superproject gitlink changes into the submodules.
In order to ensure a current tracking branch state, update --remote fetches the submodule’s remote repository before calculating the SHA-1. If you don’t want to fetch, you
should use submodule update --remote --no-fetch.
Use this option to integrate changes from the upstream subproject with your submodule’s current HEAD. Alternatively, you can run git pull from the submodule, which is
equivalent except for the remote branch name: update --remote uses the default upstream repository and submodule.<name>.branch, while git pull uses the submodule’s
branch.<name>.merge. Prefer submodule.<name>.branch if you want to distribute the default upstream branch with the superproject and branch.<name>.merge if you want a more
native feel while working in the submodule itself.
```
----
My install script ends up looking retarded:
```
# -- gitsubmodules
# - set up pytorch-meta-dataset git submodule
cd ~/diversity-for-predictive-success-of-meta-learning/
# adds the submodule to the .gitmodules file & pull the project
git submodule add -f -b hdb --name pytorch-meta-dataset git@github.com:brando90/pytorch-meta-dataset.git pytorch-meta-dataset/
git submodule update --init --recursive --remote pytorch-meta-dataset
# - set up meta-dataset git submodule
# adds the submodule to the .gitmodules file & pull the project
git submodule add -f -b master --name meta-dataset git@github.com:brando90/meta-dataset.git meta-dataset/
# - git submodule update to fetch all the data from that project
git submodule update --init --recursive --remote meta-dataset
# - initialize your local configuration file
git submodule init
# - check the submodules
git submodule status
```
why do I need to specify the same thing so many times? What is the point of the .gitmodules file then at all? **It can't even update things properly without screwing up the rest of the subdmodules**
Look at the branchdes:
```
(meta_learning) brandomiranda~/diversity-for-predictive-success-of-meta-learning ❯ git submodule status
ca81edbf5093ec5ea1a1f5a4b31ec4078825f44b meta-dataset (arxiv_v1-200-gca81edb)
6e60161962ae3fa309335da7aa1c675c75ecca54 pytorch-meta-dataset (heads/hdb)
```
they don't even match my .gitmodules
```
[submodule "pytorch-meta-dataset"]
path = pytorch-meta-dataset
url = git@github.com:brando90/pytorch-meta-dataset.git
branch = hdb
[submodule "meta-dataset"]
path = meta-dataset
url = git@github.com:brando90/meta-dataset.git
branch = master
```
----
related:
- https://stackoverflow.com/questions/1777854/how-can-i-specify-a-branch-tag-when-adding-a-git-submodule
- https://stackoverflow.com/questions/74988266/how-do-i-pull-newly-specified-submodules-that-i-just-added-in-my-gitmodules-fil?noredirect=1&lq=1
- cross: https://www.reddit.com/r/git/comments/101urnl/why_do_i_need_to_add_the_remote_to_gits_submodule/
- quora cross: https://www.quora.com/unanswered/Why-do-I-need-to-add-the-remote-to-gits-submodule-when-I-specify-the-branch-in-the-gitmodule-file
-----
Brando Miranda
brandojazz@gmail.com
reply other threads:[~2023-01-03 19:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7F5A9722-527A-48C9-9A1C-8499FDDCF02A@gmail.com \
--to=brandojazz@gmail.com \
--cc=brando9@stanford.edu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).