在裸仓库中获取“致命的:该操作必须在工作树中运行?” [英] Getting “fatal: This operation must be run in a work tree?” on bare repository

查看:903
本文介绍了在裸仓库中获取“致命的:该操作必须在工作树中运行?”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当谈到git时,我是一名新手,并且我通过一些视频教程此处

I'm a newbie when it comes to git and i went through some video tutorials here

a>

看完这些教程后,我尝试使用ssh与我的朋友建立一个git回购

注意:

Note:


  • 我们正在使用mac snow leopard

  • Git版本为1.7.5.4

我设法在一个文件夹中设置我的代码让我们说'folder1'使用

I managed to set up my code in a folder lets say 'folder1' using

git init

它包含我的代码文件。

然后我在我的朋友机器上创建一个空的存储库,可以说' folder2 ',然后我将 folder2 一个裸仓库使用

Then I create an empty repository on my friends machine lets say 'folder2', and I made folder2 a bare repository using

git init --bare --shared

现在我想将共享库设置为 folder1 的存储库s代码
在此之后,我尝试使用ssh将裸露的repo添加到远程仓库中。

Now I wanted to setup the shared repo as the repository for folder1's code After this, I tried to add the remote on the bare repo using ssh

git remote add origin myFriend@hisIp:/LocationToFile

在此之后,我推送了代码,它给了我一个成功的消息

After this, I pushed the code which gave me a successful message

现在问题是git repo' folder2 '仍然显示一个空的回购(与一个空的存储库的文件夹),我不能在 folder2 中执行git操作作为
甚至如果我做了 git status ,我得到了致命的:这个操作必须在工作树中运行

Now the issue is that the git repo 'folder2' is still show an empty repo (with the folders of an empty repository) and I cant perform git operations in folder2 as even if I do "git status", I get "fatal: This operation must be run in a work tree"

推荐答案

由于它是一个裸回购,它没有工作树。请参见什么是实际的差异Bare and non-Bare repository?

Since it is a bare repo, it has no working tree. See "What's the -practical- difference between a Bare and non-Bare repository?".

您应该在本地克隆folder2 repo,以执行您的命令。

You should clone locally that folder2 repo, in order to execute your commands.

# on server:
cd /path/to/folder2
git clone folder2 folder2b
cd folder2b
git status

注意:最好按照bare repo目录的命名约定: folder2.git (而不是 folder2

Note: It would be best to follow the naming convention for bare repo directory: folder2.git (instead of folder2)

这篇关于在裸仓库中获取“致命的:该操作必须在工作树中运行?”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆