我在裸存储库中有/ hooks/post-update这个简单的钩子:
#!/bin/sh
git-update-server-info
GIT_WORK_TREE=/home/user/apps/application-site/dev git checkout -f develop
GIT_WORK_TREE=/home/user/apps/application-site/dev git submodule update --init
GIT_WORK_TREE=/home/user/apps/application-site/master git checkout -f master
GIT_WORK_TREE=/home/user/apps/application-site/master git submodule update --init
Run Code Online (Sandbox Code Playgroud)
存储库有一些子模块,我期望将其推送到生产服务器,并检查两个目录上的两个分支,因此我可以在以后有一个dev.myapp.com用于开发分支,www.myapp.com用于主分支,所有这些也更新了分支上的子模块.
Checkout按预期工作,但不是子模块更新--init,:'(
远程输出会引发此错误.
remote: Switched to branch 'develop'
remote: You need to run this command from the toplevel of the working tree.
remote: Switched to branch 'master'
remote: You need to run this command from the toplevel of the working tree.
Run Code Online (Sandbox Code Playgroud)
我不太清楚该怎么做.
答案是完全按照git告诉你的那样做,这是:
remote: You need to run this command from the toplevel of the working tree.
Run Code Online (Sandbox Code Playgroud)
那样做吧.这是一个示例post-update
钩子:
#!/bin/sh
export GIT_DIR=$(pwd)
cd /home/lars/projects/stackoverflow/gitstuff/worktree
git checkout -f master
git submodule init
git submodule update
Run Code Online (Sandbox Code Playgroud)
这假定:
core.bare
是 false
receive.denyCurrentBranch
是ignore
.你需要这个,因为否则你会在core.bare
设置为的情况下进入存储库时出错false
.......似乎在我的有限测试中工作.