The working tree in Git consists of all the files and folders in your project outside the .git folder. It represents the current state of your project on your local system. Any modifications, additions, or deletions you make are tracked here. You can view these changes using git status. Unlike local repositories, remote repositories (like GitHub) do not have a working tree; they only store commits.
- Files and folders outside
.gitbelong to the working tree .gitfolder is not part of the working tree- Tracks changes made to files (modified, added, deleted)
- Changes can be viewed with
git status - Serves as a bridge between local edits and the staging area
- Remote repositories do not have a working tree
The repositories on Github, however, don't have a working tree. However, on the local repository, we can get a good overview of the working tree. The command that helps us to get insight into the mechanics of the working tree is as follows:
git statusLet us look at an example, we will create an empty directory and initialize it to a git repository using git init command.

As discussed above the .git folder is not part of the working tree, the files that we would be adding to the directory now will become part of Working Tree.
Let's add a new file demo.txt to our directory and then check our working tree using the command git status.

We can see there is some message given to us by the git status command, which states that there is a file called demo.txt which is there in our working tree which is currently being untracked.
Let's add our file to the staging area and let's observe the git status command.

Our file is now added to the staging area but we again got a message saying that we have not added commit. Let's add commit using git commit command and check our working tree status.

Now we got a message that there is nothing to commit and the working tree is clean. Let's modify our demo.txt and then again observe our working tree.

As soon as we modified our demo.txt our working tree informs us that there is a change in the working directory. Let's add these changes to the staging area and commit these changes.

So again, our working tree now becomes clean. Now, let's observe what happens if we delete our file, will the working tree show those changes?

And we can see that after deleting our file, we get the message that there is a change that is untracked. So, let's add those changes to the staging area and commit them.

So again our working tree becomes clean, let us look at the commits that we have had till now. So, in a similar manner, one can try on more examples to get a better understanding of the working tree.



