Git:“工作目录"到底在哪里? [英] Git: Where exactly is the "working directory"?

查看:564
本文介绍了Git:“工作目录"到底在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读一些Git教程.始终提及"工作目录"的概念,但是,我阅读的所有教程或文档都没有指出"工作目录"的位置或位置.

我以为这实际上是.git的父目录,也就是我在其中运行git init的目录.但是我正在观看的视频教程中谈到了什么都没提交和"工作目录干净":

实际上,您实际上可以制作存储库的副本,并进行复制 复制,使其没有工作目录,这实际上是 称为裸克隆.这实际上就是GitHub所使用的.

如果我对"工作目录"的理解是正确的,那么存储库怎么没有"工作目录"呢?当它说GitHub使用"裸克隆"时,这是什么意思?

解决方案

这有望为我们清除一切:

使用git init创建的存储库之间有什么区别 命令和git init --bare命令?

使用git init命令创建的存储库称为工作库 目录.在存储库的顶级文件夹中,您会找到 两件事:

A .git subfolder with all the git related revision history of your repo
A working tree, or checked out copies of your project files.

使用git init --bare创建的存储库称为裸存储库.他们 的结构与工作目录略有不同.首先, 它们不包含源文件的工作副本或已签出副本.和 其次,裸仓库在根目录中存储仓库的git修订历史记录 资料库的资料夹,而不是.git子资料夹.注意…裸露 通常会给存储库一个.git扩展名.

来自 John Saints-裸露的东西git存储库?

裸git克隆不包含已签出代码的工作目录,换句话说.
可以将它视为.git目录(Git数据库)而没有其他任何内容.

I am going through some Git tutorials. The concept of a "working directory" keeps being mentioned, however, none of the tutorials or documents I read points out where or what this "working directory" is.

I have thought that it was actually the .git's parent directory, a.k.a the directory I run git init in. But the video tutorial I am watching talks about the state of nothing to commit and "working directory clean":

In fact you can actually make a copy of the repository, and make that copy so that it does not have a working directory, this is actually called the bare clone. This is actually what GitHub uses.

If my understanding of the "working directory" is correct, how can a repository not have a "working directory"? And what does it mean, when it says that GitHub uses a "bare clone"?

解决方案

This should hopefully clear things up for us:

What is the difference between a repository created using the git init command and the git init --bare command?

Repositories created with the git init command are called working directories. In the top level folder of the repository you will find two things:

A .git subfolder with all the git related revision history of your repo
A working tree, or checked out copies of your project files.

Repositories created with git init --bare are called bare repos. They are structured a bit differently from working directories. First off, they contain no working or checked out copy of your source files. And second, bare repos store git revision history of your repo in the root folder of your repository instead of in a .git subfolder. Note… bare repositories are customarily given a .git extension.

Taken from John Saints - What is a bare git repository?

A bare git clone does not contain a working directory of checked out code, in other words.
Think of it as just the .git directory (the Git database) without anything else.

这篇关于Git:“工作目录"到底在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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