Git: Where exactly is the "working directory"?

Viewed 44984

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"?

7 Answers

To answer OP's 3 questions:

Q1: Where exactly is the "working directory"?
A1: "A Git project normally consists of a working directory with a '.git' subdirectory at the top level." (source: https://git-scm.com/docs/git#_discussion)

Q2: How can a repository not have a "working directory"?
A2: A Git "bare repository" is one example (source: https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server#_getting_git_on_a_server)

Q3: And what does it mean, when it says that GitHub uses a "bare clone"?
A3: Read the documentation for the --bare option on git clone, here: https://www.git-scm.com/docs/git-clone

Do you work directly in the local repos?

When I follow Microsoft's instructions [ref. https://docs.microsoft.com/en-us/azure/devops/repos/git/clone?view=azure-devops&tabs=visual-studio ], that's where I end up opening the .sln solution file. That seems wrong to me and unfortunate, because I prefer to work on code on my massive D: drive (D:\dev) rather than in C:\Users\\source\repos, where the repos are kept by default (I don't mind the local repos being kept there - it's not ideal - as long as I can work in my D:\dev area).

Related