【问题标题】:How do I get my files uploaded with post-receive?如何使用 post-receive 上传我的文件?
【发布时间】:2015-05-16 22:24:07
【问题描述】:

我有以下 shell 脚本作为 post-receive 钩子,它应该将我的工作副本复制到我的 /mnt/repo/ 文件夹中:

#!/bin/sh
rm -rf /tmp/repo/
rm -rf /mnt/repo/*

mkdir /tmp/repo/ && cd /tmp/repo/

git init
git remote add origin file:///home/git/repos/repo.git
git fetch
git checkout development

cp -r /tmp/repo/* /mnt/repo/

如果我在本地运行它,它工作得很好。但是,如果它在 push 之后由 Git 运行,它将无法工作,并且我在本地 Git Bash 中得到以下输出:

$ git push local development
git@192.168.178.88's password:
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 349 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Initialized empty Git repository in /tmp/repo/
remote: From file:///home/git/repos/repo
remote:  * [new branch]      development -> origin/development
remote:  * [new branch]      release    -> origin/release
remote: fatal: This operation must be run in a work tree
To git@192.168.178.88:repos/repo.git
   01568cc..ee31229  development -> development

此外,在我的/tmp/repo/mnt/repo 文件夹中,我的文件夹结构如下:

drwxr-xr-x  7 git  git  220 Mar 14 13:47 .
drwxrwxrwt  3 root root  60 Mar 14 13:47 ..
drwxr-xr-x  2 git  git   40 Mar 14 13:47 branches
-rw-r--r--  1 git  git  183 Mar 14 13:47 config
-rw-r--r--  1 git  git   73 Mar 14 13:47 description
-rw-r--r--  1 git  git  240 Mar 14 13:47 FETCH_HEAD
-rw-r--r--  1 git  git   23 Mar 14 13:47 HEAD
drwxr-xr-x  2 git  git  200 Mar 14 13:47 hooks
drwxr-xr-x  2 git  git   60 Mar 14 13:47 info
drwxr-xr-x 44 git  git  880 Mar 14 13:47 objects
drwxr-xr-x  5 git  git  100 Mar 14 13:47 refs

【问题讨论】:

    标签: git git-post-receive


    【解决方案1】:

    这是一个新的存储库,因此尚未附加工作树。

    Read here 了解更多详情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 2012-04-16
      • 1970-01-01
      • 2017-12-23
      • 2011-07-22
      • 1970-01-01
      • 2011-04-22
      相关资源
      最近更新 更多