In my experience so far with reading about GIT, I have found that Working Directory seems to be a bit of an overloaded term. Sometimes people mean the directory on the hard drive into which a branch is checked out e.g. when cloning a repo, the branch is checked out into the directory of the new clone of the repo.
But sometimes people just mean an abstract location which contains untracked files and modified files i.e. the red text when you enter git status
I was hoping someone could give me an idea of the official definition of the working directory. Even that online Pro Git book seems to be a bit vague as to exactly what it is.
Note: I use it every day, I just want to know what it is.
Cheers
As stated in the Git Documentation: The working directory is a single checkout of one version of the project. This essentially means if you checkout a branch (e.g. master) and are sat on a particular commit (e.g. HEAD), your working directory is the "umbrella" term for all your files and folders.
The repository is essentially the . git hidden folder inside the working directory (workspace). The working directory (workspace) is essentially your project folder. Also note the term directory is basically synonymous to the term folder.
The Local Repository is the . git/ subdirectory inside the Working Directory.
Th Working Tree in Git is a directory (and its files and subdirectories) on your file system that is associated with a repository. It's full of the files you edit, where you add new files, and from which you remove unneeded files.
From git commit-tree
, a tree represents a particular directory state of a working directory.
So while the working directory represents where a repo is checked out, a working tree represents its status.
A git status
shows a "working tree", meaning the state of a working directory.
A working directory references the "where", a working tree references the "what" (what it contains, its files tracked or not tracked)
Note that git 2.5 (Q2 2015) will allow multiple working trees for a given local repo.
That means you will use multiple working directories (with git worktree add <path> [<branch>]
), and each working directory can contain a different working tree: you can checkout different branches per path, for instance, which means each directory contains a different state of the same repo: multiple working trees.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With