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

标签 git laravel version-control

我是 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://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcaeb3b3a89cb9a4bdb1acb0b9f2bfb3b1" rel="noreferrer noopener nofollow">[email protected]</a>/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/

相关文章:

git - Svn 或 Git 客户端(或插件)查找丢失或损坏的文件

git - VSTS GIT 将开发分支 merge 到 master 中,而 master 却没有认为这是提前 1 个变更集?

linux - GitLab SSH 请求密码并忽略 SSH key

git - 如何从暂存区中删除单个文件(撤消 git add)?

php - 当我从 URL 中删除 public 并且在 url 上添加 Public 时,Laravel Bootstrap Styling 不起作用

php - Laravel 中缺少文件

ios - CocoaPods:指向 pod spec 中的一个分支

git - 如何 merge 存储库副本

Laravel 8 部署在 Ubuntu 上,但不断收到 : Undefined variable

svn - 相互依赖模块的版本控制