Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

Git submodule on remote bare

I've setup my environment so I can push to a remote bare repository. I used these commands to set up the remote repository:

$ mkdir ~/website.git && cd ~/website.git
$ git init --bare

And

$ cat > hooks/post-receive

#!/bin/sh
GIT_WORK_TREE=/var/www/website git checkout -f

$ chmod +x hooks/post-receive

And on my local environment:

$ git remote add web ssh://website.com/home/website.git
$ git push web +master:refs/heads/master

Now I can deploy to this remote using git push web, and everything works great..

The problem: Submodules

I have a few submodules on my project that aren't getting initialized/updated at the remote repository. I can't run git submodule update on the bare because it's bare, and I can't run it on the /var/www/website folder because it's just a copy of the files and not a git repo.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I figured out another solution which looks rather clean to me. Just give git all the info it needs to perform the submodule stuff:

$ cd /path/to/your/git_work_tree
$ git --git-dir=/path/to/your/bare_repo.git --work-tree=. submodule init
$ git --git-dir=/path/to/your/bare_repo.git --work-tree=. submodule update

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...