gpt4 book ai didi

GIT 推送 - 远程 : fatal: This operation must be run in a work tree

转载 作者:太空狗 更新时间:2023-10-29 14:42:37 25 4
gpt4 key购买 nike

我是 GIT 新手。我使用命令创建存储库:

cd /home/user_name
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare

然后在 hooks 目录中,我创建了 post-receive 文件并在其中添加:

#!/bin/sh
git --work-tree=/home/user_name/dev.ireserve.com --git-dir=/home/user_name/repo/site.git checkout -f

之后,我添加权限:chmod +x post-receive

在我运行的 laravel 项目目录中的本地机器上:

git init

然后我运行:

git remote add live ssh://root@example.com/home/user_name/repo/site.git

通常之后:

git add .
git commit -m "my message"

最后:

git push live master

但我收到一条消息:

remote: fatal: This operation must be run in a work tree

enter image description here

为什么会出现这个错误?什么是问题?

最佳答案

从评论来看,你在两边都有 1 个目录,你需要开始创建版本,这样你才能使用 GIT 的真正力量。

如果您愿意使用GIT add,您需要创建分支(版本)。

检查这个 answer

要添加分支,请检查此 tutorial

这是来自 start 的教程。

恕我直言,这是最好的教程;用于 GIT。

这将节省大量的精力和时间。

编码愉快!

关于GIT 推送 - 远程 : fatal: This operation must be run in a work tree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49140018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com