How to add a git repo as a submodule of itself? (Or: How to generate GitHub Pages programmatically?)?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

In this case, the behaviour seems to be that git is trying to set the origin of the original repository to be the origin of the submodule. This is confirmed by the git submodule man page, which says my emphasis: repository> is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with .

/ or ../), the location relative to the superproject’s origin repository A workaround that seems fine for me is to do the following: Define origin to be the absolute path to this repository - we'll remove # this later: $ cd /tmp/main/ $ git remote add origin /tmp/main/ # Now add the submodule: $ git submodule add -b gh-pages . / gh-pages Initialized empty Git repository in /tmp/main/gh-pages/. Git/ Branch gh-pages set up to track remote branch gh-pages from origin.

# Now . Gitmodules looks sensible: $ cat . Gitmodules submodule "gh-pages" path = gh-pages url = .

/ # However, the origin for the submodule isn't what we want: $ cd gh-pages $ git remote -v origin /tmp/main/ (fetch) origin /tmp/main/ (push) # So remove it and add the right origin (just ".."): $ git remote rm origin $ git remote add origin .. # Change back to the main repository and commit: $ cd .. $ git commit -m "Added the gh-pages branch as a submodule of this repository" master 6849d53 Added the gh-pages branch as a submodule of this repository 2 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 . Gitmodules create mode 160000 gh-pages This seems to work OK - if I change into another directory and do: $ cd /var/tmp $ git clone --recursive /tmp/main the submodule is updated and initialized correctly (Update: although as you point out in a comment below origin in the submodule will be set to the URL you cloned from rather than ) As for whether this is a good idea or not: I've worked on a project which used a similar setup in the past and which subsequently abandoned it. The reasons for this, however, were (a) that the alternative branches in the main repository were huge and bloated the repository even for people who didn't need the submodule and (b) that it caused confusion for people who weren't sure what was going on For your use case, however, I think it's a rather neat solution :).

In this case, the behaviour seems to be that git is trying to set the origin of the original repository to be the origin of the submodule. This is confirmed by the git submodule man page, which says my emphasis: is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with .

/ or ../), the location relative to the superproject’s origin repository. A workaround that seems fine for me is to do the following: # Define origin to be the absolute path to this repository - we'll remove # this later: $ cd /tmp/main/ $ git remote add origin /tmp/main/ # Now add the submodule: $ git submodule add -b gh-pages . / gh-pages Initialized empty Git repository in /tmp/main/gh-pages/.

Git/ Branch gh-pages set up to track remote branch gh-pages from origin. # Now . Gitmodules looks sensible: $ cat .

Gitmodules submodule "gh-pages" path = gh-pages url = . / # However, the origin for the submodule isn't what we want: $ cd gh-pages $ git remote -v origin /tmp/main/ (fetch) origin /tmp/main/ (push) # So remove it and add the right origin (just ".."): $ git remote rm origin $ git remote add origin .. # Change back to the main repository and commit: $ cd .. $ git commit -m "Added the gh-pages branch as a submodule of this repository" master 6849d53 Added the gh-pages branch as a submodule of this repository 2 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 . Gitmodules create mode 160000 gh-pages This seems to work OK - if I change into another directory and do: $ cd /var/tmp $ git clone --recursive /tmp/main/ ... the submodule is updated and initialized correctly.(Update: although as you point out in a comment below, origin in the submodule will be set to the URL you cloned from rather than ..) As for whether this is a good idea or not: I've worked on a project which used a similar setup in the past and which subsequently abandoned it.

The reasons for this, however, were (a) that the alternative branches in the main repository were huge and bloated the repository even for people who didn't need the submodule and (b) that it caused confusion for people who weren't sure what was going on. For your use case, however, I think it's a rather neat solution :).

Looking good! The origin of the submodule in the clone is set to the absolute path of the clone, but I think that is a problem only if the clone is moved, right? And even then, simply updating the origin of the clone's submodule should be sufficient.

– Thomas Mar 14 at 12:18 @Thomas: ah, yes - I didn't notice that. I've updated my answer to include that detail. However, as you say, you can just change origin in the submodule.(I mostly find I have to change origin in submodules anyway, since it's polite to include a publicly accessible URL in .

Gitmodules, but typically I'll prefer to use SSH if I can. ) – Mark Longair Mar 14 at 12:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions