Because I don't want to spend +$12 for the simple-to-use github.com private hosting, I place a lot of my code libraries in small repositories on a shared hosting account. This allows me to have as many code repos as I want.
Since those repos don't take any resources to sit there I also put a couple very light sites on that account to maximize my usage. These sites actually use some of those same code repos as submodules of their projects.
So, I push/pull code f开发者_StackOverflowor each repo and site over ssh. The sites themselves setting just a couple directives down also pull those submodules.
So I have a simplesite.tld project on my pc with a submodule that looks like this:
[submodule "modules/blog"]
path = modules/blog
url = user@simplesite.tld:~/git/modules/blog/
Then I push the code to the simplesite.tld and login to the shared host through SSH and update the simplesite.tld modules
git submodule update
But it asks me for my SSH password for the "user" in order to login and get the repo code. Which is just an annoyance since the repo is on the same server.
So is there a better submodule link that I can use that both foreign computers (like my PC) and projects in the same harddrive can both use?
You could set up public key authentication over SSH to avoid having to type in your password each time.
You can probably use the basic HTTP transport for git to provide global read-only access to your repos (assuming that's ok), or, restrict access via .htaccess
directives. That should work fine with most shared hosting accounts. That will let you use the same url in both places.
Or, alternatively, you could use something other than submodules (which I personally have found to be rather inadequate for many potential use cases). For example, I like mr. It fulfils a slightly different role than submodules, but it can probably be made to work.
I suppose you have already solved your issue with redundant password requests :)
If not, I recently had similar problem, which I solved by using relative urls to submodules - see the details at Git submodules using relative urls.
精彩评论