Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VPS上的Git远程存储库接受推送但不创建文件?_Git_Ssh_Repository_Vps - Fatal编程技术网

VPS上的Git远程存储库接受推送但不创建文件?

VPS上的Git远程存储库接受推送但不创建文件?,git,ssh,repository,vps,Git,Ssh,Repository,Vps,我正在与Digital Ocean VPS合作,获得了Ubuntu服务器12.0.4,并尝试按照上的一些说明进行操作 但是,一旦我从笔记本电脑上按下按钮,VPS就会做出以下响应: Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 335 bytes, done. Total 3

我正在与Digital Ocean VPS合作,获得了Ubuntu服务器12.0.4,并尝试按照上的一些说明进行操作

但是,一旦我从笔记本电脑上按下按钮,VPS就会做出以下响应:

Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 335 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
remote:            [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
remote:            [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
remote:            [-c name=value] [--help]
remote:            <command> [<args>]
remote: 
remote: The most commonly used git commands are:
remote:    add        Add file contents to the index
remote:    bisect     Find by binary search the change that introduced a bug
remote:    branch     List, create, or delete branches
remote:    checkout   Checkout a branch or paths to the working tree
remote:    clone      Clone a repository into a new directory
remote:    commit     Record changes to the repository
remote:    diff       Show changes between commits, commit and working tree, etc
remote:    fetch      Download objects and refs from another repository
remote:    grep       Print lines matching a pattern
remote:    init       Create an empty git repository or reinitialize an existing one
remote:    log        Show commit logs
remote:    merge      Join two or more development histories together
remote:    mv         Move or rename a file, a directory, or a symlink
remote:    pull       Fetch from and merge with another repository or a local branch
remote:    push       Update remote refs along with associated objects
remote:    rebase     Forward-port local commits to the updated upstream head
remote:    reset      Reset current HEAD to the specified state
remote:    rm         Remove files from the working tree and from the index
remote:    show       Show various types of objects
remote:    status     Show the working tree status
remote:    tag        Create, list, delete or verify a tag object signed with GPG
remote: 
remote: See 'git help <command>' for more information on a specific command.
remote: hooks/post-receive: 3: hooks/post-receive: checkout: not found
To ssh://root@ip.my.vps.address/gits/cleu/cleu.git
   b21f9df..8eb93e0  master -> master
/gits/cleu.git/hooks/post receive
作为内容获取:

#!/bin/sh
git --work-tree=/sites/node/cleu --git-dir=/gits/cleu.git
checkout -f
我还得到了
/sites/node/cleu/
文件夹

在我的远程机器上,repo文件夹没有:

/gits/cleu.git/
git init
git remote add live ssh://user@vpsipadress/gits/cleu.git
# Some files addition
git add .
git commit -m "Start"
git push live master
我通过ssh登录到vps,然后检查我的推送文件,那里有任何东西。正确的步骤是什么?

此语句:

/gits/cleu.git/hooks/post receive
作为内容获取:

#!/bin/sh
git --work-tree=/sites/node/cleu --git-dir=/gits/cleu.git
checkout -f
显示,表明
cleu.git
是一个“裸”存储库。(man git init中有一些信息,但实际上并不多。)通常,git回购协议如下所示:

.../some-parent-dir
    .git/
        config
        description
        HEAD
        hooks
        ... and so on ...
    < your files >
.../some-parent-dir.git
    config
    description
    HEAD
    hooks
    ... and so on ...
裸回购协议只是没有工作目录的回购协议。它对于存储存储库及其历史非常有用,但实际上不适合使用它。您经常在远程设备上看到它,在那里没有工作目录的意义,因为没有人在那里工作

一些迹象表明,这是一种无担保回购,而不是普通回购:

  • 没有
    .git
    目录
  • .git
    目录中的所有内容都在主文件夹中
此外,路径以
.git
结尾,例如,
cleu.git
,而不仅仅是
cleu
。不过,这只是一种常见的命名约定,所以不要依赖它,但裸回购协议的命名方式很常见

但数据在哪里?

历史记录在
对象中
。它的存储方式很复杂;不要试图直接得到它。相反,只需尝试克隆回购协议:

git clone ssh://user@vpsipadress/gits/cleu.git
cd cleu
# Now take a look around.
除非您想了解更多关于
git
如何在内部工作的知识。这真的很酷,但有点复杂。应该提供一个起点

关于这个脚本…

钩子脚本
post-receive
只是一个可执行文件,这里只是一个shell脚本:

#!/bin/sh
git --work-tree=/sites/node/cleu --git-dir=/gits/cleu.git
checkout -f
但是,请注意,shell脚本需要命令位于一行,如:

#!/bin/sh
git --work-tree=/sites/node/cleu --git-dir=/gits/cleu.git checkout -f
(因为这里的命令是git checkout),或者,您可以使用行连续体将其分解:

#!/bin/sh
git --work-tree=/sites/node/cleu --git-dir=/gits/cleu.git \
    checkout -f
我将它缩进,以便更清楚地表示延续;这是一种风格,不是严格要求,但我觉得它更具可读性。你甚至可以:

#!/bin/sh
git \
    --work-tree=/sites/node/cleu \
    --git-dir=/gits/cleu.git \
    checkout -f

我克隆了,是的,我在笔记本电脑的克隆目录中把文件放在哪里了。但是我登录到我的vps,在预期的目录下有任何文件没有文件或者没有您预期的文件?您暗示存在
hooks/post-receive
(这就是为什么我认为这是一个简单的回购:通常,这是
.git/hooks/post-receive
)。裸repo不像普通文件那样包含您的文件:它只存储原始git对象和元数据(例如分支、标记等)。裸回购看起来不像普通回购:它看起来像一个
.git
目录。我希望文件存在于:
/sites/node/cleu
。因为我将
git--work tree=/sites/node/cleu--git dir=/gits/cleu.git
添加到
post receive
中,也许我不想要一个简单的repo,我真的需要一个普通的repo clonedrop工作。就像在我的笔记本电脑上使用Github和克隆回购一样。啊,我明白了!这是不是像在你的帖子里一样,在另一行上写着“签出”?它需要与
git
命令位于同一行,或者在行尾有一个
`来连接这两个命令。否则,
git`命令将不起任何作用,
checkout
将是一个找不到的命令。(您是否有显示该脚本输出的日志?)