在post hook上使用git submodule update --init [英] Using git submodule update --init on a post hook

查看:475
本文介绍了在post hook上使用git submodule update --init的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 #!/ 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

存储库有一些子模块,我期待推送到生产服务器,并检查两个目录上的两个分支,所以我可以稍后为开发分支dev.myapp.com和master分支www.myapp.com,并且所有这些更新也是子模块
$ b 结账工作正常,但不是子模块更新--init,:'(



远程输出引发这个错误。

  re mote:切换到分支'develop'
remote:您需要从工作树的顶层运行此命令。
remote:切换到分支'master'
remote:您需要从工作树的顶层运行此命令。

我不太确定该做什么。

解决方案

答案就是完成git告诉你的事情,即:

  remote:你需要从工作树的顶层运行这个命令。 

那就这么做。这里有一个示例 post-update hook:



$ $ $ $ $ $ $ $# sh

export GIT_DIR = $(pwd)

cd / home / lars / projects / stackoverflow / gitstuff / worktree

git checkout -f master
git submodule init
git submodule update

这里假设:




  • core.bare false

  • receive.denyCurrentBranch 忽略。你需要这个,否则你会遇到一个错误,将 core.bare 设置为 false 。 / li>


...似乎可以在我的有限测试中工作。


I have this simple hook on /hooks/post-update inside a bare repository:

#!/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

The repository has some submodules, that I am expecting is pushing to production server, and checkout the two branches on two directories, so can I have later a dev.myapp.com for the development branch and www.myapp.com for the master branch, and all this updating also the submodules on the branches.

Checkout is working as expected, but not the submodule update --init, :'(

The remote output raises this errors.

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.

I am not quite sure what to do.

解决方案

The answer is to do exactly what git is telling you, which is:

remote: You need to run this command from the toplevel of the working tree.

So do that. Here's a sample post-update hook:

#!/bin/sh

export GIT_DIR=$(pwd)

cd /home/lars/projects/stackoverflow/gitstuff/worktree

git checkout -f master
git submodule init
git submodule update

This assumes that:

  • core.bare is false
  • receive.denyCurrentBranch is ignore. You need this because otherwise you'll get an error pushing into a repository with core.bare set to false.

...and seems to work in my limited testing.

这篇关于在post hook上使用git submodule update --init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆