Вопрос

i've got a real fun git layout for my android project... everything has been working beautifully.

the structure is essentially 1 master project with a couple inner submodules. one of the inner submodules itself has a submodule.

i can either throw the --recursive flag in when i clone my project or I can clone it regularly and then traverse through the submodules folder and do a

git submodule init
git submodule update

I recently decided that it would be a better idea to fork the submodules that I use on github. the origin is my account Github url to my forked repo, and i've added an 'upstream' remote that points to the project creator's master so that i can pull their latest from time to time.

i just cloned my project on a newly wiped computer using the --recursive flag for the first time since forking each submodule and everything worked beautifully.

so here comes the question...

my only issue with the whole process is that each of my submodules did not come down with the upstream in there... i can cd in to each submodule and do a git remote show and only origin is visible.

it's not a big deal to go through and re-add the upstream remotes but i'd rather know what my issue here is.

another little sub-question: is there any way to add an in-line flag to that single recursive clone command that will git checkout master on each submodule?

any ideas?

Это было полезно?

Решение 2

i reached out to the good people at Github to answer the question of forked repositories not tracking added upstreams and this is what i got back:

Every clone has its own list of remotes. So each time you create a new clone you'll need to add back your preferred remotes. For this reason, it is often better to have one clone of a repository on each computer you work on and then pull changes and updates as they are published rather than creating a new clone for every task.

Другие советы

is there any way to add an in-line flag to that single recursive clone command that will git checkout master on each submodule?

Not exactly what you asked, but you can configure a submodule to follow master: see git submodule tracking latest.

After your git submodule update --init --recursive, a git submodule update --remote --recursive would update the detached HEAD to the last fetched remote HEAD.

To really checkout and update a submodule, you would need an alias, a bit as in this blog post:

git config --global alias.up-sub '!f() { cd $1 && git checkout master && git pull && git submodule update --init --recursive; }; f'

Now, to update the ‘framework’ submodule, we can just do:

git up-sub framework

Use && instead of ; to prevent losing work when you mistype the submodule name.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top