我是 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
为什么我收到这个错误?有什么问题吗?
最佳答案
从评论来看,你两边都有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/