Reputation: 24305
Sorry for such an easy question but how do I make a git repository I've added locally viewable in my master?
Details:
So this is hidden:
this is viewable:
Upvotes: 1
Views: 2239
Reputation: 1323115
Submodule is a good way to reference a fixed point in another repo history.
See "True nature of submodules".
Adding a submodule isn't enough, you must initialize it and update it:
git submodule update --init
You can also declare a submodule in order to follow a certain branch of ots upstream repo.
See "git submodule tracking latest".
If you have already declared a submodule without taking advantage of that option, see "How to make an existing submodule track a branch".
If you pull from GitHub, a simple git submodule update --init
on your server in your live repo is enough to update your submodules.
Actually, the full command would be:
git submodule update --init --recursive --force
If you push directly to your server, to see a submodule updated in a live server, you need to have:
a bare repo (you can clone, on your server, your current repo which represents your live files, but which doesn't yet display the submodule content, with the --bare
option, and push to that bare repo from your client)
a post-receive hook similar to what I describe in "Git submodule on remote bare".
That would be:
cd /path/to/your/bare/repo.git
$ cat > hooks/post-receive
#!/bin/sh
GIT_DIR=/path/to/live/repo/.git
GIT_WORK_TREE=/path/to/live/repo
cd /path/to/live/repo
git pull /path/to/your/bare/repo.git
git submodule update
$ chmod +x hooks/post-receive
Upvotes: 1